Query interface is empty when using an instance of GraphQLSchema
See original GitHub issueDescribe the bug Using typescript-resolvers plugin, QueryResolvers.Resolvers are empty when using TypeScript export schema config.
To Reproduce Steps to reproduce the behavior:
- Clone repository:
git clone -b graphql-ts-emptyQueryResolvers https://github.com/swcarlosrj/SpaceX-API.git
- Install dependencies:
yarn
- Generate types:
yarn generate
Expected behavior Get the auto generated resolver types.
Environment:
- OS: macOS Mojave 10.14.2 (18C54)
- Codegen: 0.15.0
- Node: 10.10.0
Additional context
Using Url(schema: http://localhost:4000/graphql
) schema config (it does work):
export namespace QueryResolvers {
export interface Resolvers<Context = MyContext, TypeParent = {}> {
_empty?: _EmptyResolver<Maybe<string>, TypeParent, Context>;
capsules?: CapsulesResolver<Maybe<(Maybe<Capsule>)[]>, TypeParent, Context>;
capsule?: CapsuleResolver<Maybe<Capsule>, TypeParent, Context>;
cores?: CoresResolver<Maybe<(Maybe<Core>)[]>, TypeParent, Context>;
core?: CoreResolver<Maybe<Core>, TypeParent, Context>;
...
}
...
}
Using TypeScript export(schema: src/graphql/schema/index.ts
) schema config (it does not work!):
export namespace QueryResolvers {
export interface Resolvers<Context = MyContext, TypeParent = {}> {
_empty?: _EmptyResolver<Maybe<string>, TypeParent, Context>;
}
...
}
The motivations for using this configuration is having nodemon & gql-gen watching for the schema & resolver files, having Url as schema config on gql-gen, whenever you change a file, both gql-gen & apollo server will restart where gql-gen will usually finish first then the schema: http://localhost:4000/graphql
is not available to auto generate the types.
Is there a better way to resolve this problem than the following conf (which I cannot make it work)?
schema: src/graphql/schema/index.ts
documents: src/graphql/schema/**/*.ts
overwrite: true
watch: true
require:
- ts-node/register
generates:
./src/graphql/types/types.d.ts:
plugins:
- typescript-common
- typescript-server
- typescript-resolvers
P.D.: The typescript-server plugin is working correctly, what I cannot get are the resolvers, probably I’m missing smth out on the config.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
https://github.com/Urigo/graphql-modules/pull/238 should fix it
Fixed in 0.15.2 😃