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.

Type Checking for resolvers seems broken with the latest TypeScript version

See original GitHub issue

Apparently the latest version of TypeScript has stricter type checking. This is causing issues with the basic example on the README…

const resolvers = {
  Query: {
    hello: (_, { name }) => `Hello ${name || "World"}`
  }
};

const server = new GraphQLServer({ typeDefs, resolvers });

This error is reported…

[ts]
Argument of type '{ typeDefs: string; resolvers: { Query: { hello: (_: any, { name }: { name: any; }) => string; };...' is not assignable to parameter of type 'Props<any, any, any>'.
  Types of property 'resolvers' are incompatible.
    Type '{ Query: { hello: (_: any, { name }: { name: any; }) => string; }; }' is not assignable to type 'IResolvers | undefined'.
      Type '{ Query: { hello: (_: any, { name }: { name: any; }) => string; }; }' is not assignable to type 'IResolvers'.
        Property 'Query' is incompatible with index signature.
          Type '{ hello: (_: any, { name }: { name: any; }) => string; }' is not assignable to type '(() => any) | IResolverObject | GraphQLScalarType'.
            Type '{ hello: (_: any, { name }: { name: any; }) => string; }' is not assignable to type 'GraphQLScalarType'.
              Property 'name' is missing in type '{ hello: (_: any, { name }: { name: any; }) => string; }'.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:15

github_iconTop GitHub Comments

3reactions
nihalgonsalvescommented, Nov 16, 2018

If you want to disable type-checking on the resolvers input to the GraphQLServer constructor, you can also do this instead:

const server = new GraphQLServer({
  typeDefs,
  resolvers: resolvers as any
});
1reaction
sscotthcommented, Jan 15, 2019

Still requires the workaround

Read more comments on GitHub >

github_iconTop Results From Across the Web

Type Checking for resolvers seems broken with the latest ...
Apparently the latest version of TypeScript has stricter type checking. This is causing issues with the basic example on the README... const ...
Read more >
Documentation - TypeScript 3.9
Recent versions of TypeScript (around 3.7) have had updates to the declarations of functions like Promise.all and Promise.race . Unfortunately, that introduced ...
Read more >
@homebound/graphql-typescript-resolver-scaffolding - npm
This is a graphql-code-generator plugin that generates scaffolding for resolvers. The generated scaffolds are extremely simple, ...
Read more >
Semantic Versioning for TypeScript Types - Ember RFCs
Adding a new TypeScript version to the support matrix may cause breaking changes. When it does not, adding it is a normal minor...
Read more >
Migrating to Apollo Server 4 - Apollo GraphQL Docs
A new @apollo/server package, combining numerous smaller packages and including ... of @apollo/server 's type definitions for older versions of TypeScript, ...
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