0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[graphql-codegen resolver]Failed to load schema from http://localhost

Last updated at Posted at 2023-04-22

resolver codegenのエラーメモ

エラー

Failed to load schema from http://localhost:3000/graphql:

やりたいこと

schema/の定義に従ってresolverの型をcodegen/resolver.tsに出したい

ディレクトリ
src/
├── graphql
│   ├── codegen
│   ├── resolver
│   └── schema

codegen

codegen.ts
import type { CodegenConfig } from '@graphql-codegen/cli'

const config: CodegenConfig = {
  overwrite: true,
  schema: 'http://localhost:3000/graphql',
  documents: ['src/graphql/**/*.{gql,graphql}'],
  generates: {
    'src/graphql/codegen/resolver.ts': {
      plugins: ['typescript', 'typescript-resolvers'],
    },
    // ...
  }
}
export default config

設定について

  • schema: graphqlのエンドポイントURL
  • documents: GraphQLドキュメント(path or 配列)
  • generates: 出力パス
    • plugins: プラグイン配列

解決

localhost => 127.0.0.1に変更

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?