question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Query interface is empty when using an instance of GraphQLSchema

See original GitHub issue

Describe the bug Using typescript-resolvers plugin, QueryResolvers.Resolvers are empty when using TypeScript export schema config.

To Reproduce Steps to reproduce the behavior:

  1. Clone repository: git clone -b graphql-ts-emptyQueryResolvers https://github.com/swcarlosrj/SpaceX-API.git
  2. Install dependencies: yarn
  3. 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:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
kamilkisielacommented, Dec 19, 2018
1reaction
dotansimhacommented, Dec 24, 2018

Fixed in 0.15.2 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

GraphQL schema basics
This schema defines a hierarchy of types with fields that are populated from your back-end data stores. The schema also specifies exactly which...
Read more >
How to define an empty Object Type in a GraphQL schema?
I want to be able to use extend type Query or extend type Mutation to add queries or mutations to the overall schema....
Read more >
Schemas and Types - GraphQL
On this page, you'll learn all you need to know about the GraphQL type system and how it describes what data can be...
Read more >
Interfaces - Graphene-Python
For example, you can define an Interface Character that represents any character in the Star ... The full GraphQL schema definition will look...
Read more >
Spring for GraphQL Documentation
GraphQL instance to use that also includes a builder API to build that ... the GraphQL Java SchemaGenerator to create the graphql.schema.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found