Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graphql-resolvers: typescript fails for BigInt #3256

Closed
Andrei-Stepanov opened this issue Sep 3, 2021 · 0 comments
Closed

graphql-resolvers: typescript fails for BigInt #3256

Andrei-Stepanov opened this issue Sep 3, 2021 · 0 comments

Comments

@Andrei-Stepanov
Copy link

    "graphql": "^15.5.1",
    "graphql-bigint": "^1.0.0",
    "@types/graphql-bigint": "^1.0.0"

Hello,

I am trying to write code:

import BigInt from 'graphql-bigint'

const ExampleType = new GraphQLObjectType({
  name: 'ExampleType',
  fields: () => ({
    version: { type: GraphQLString },
    timestamp: { type: BigInt },
  }),
});

This gives error message:

Type '() => { version: { type: graphql.GraphQLScalarType; }; timestamp: { type: GraphQLScalarType; }; }' is not assignable to type 'Thunk<GraphQLFieldConfigMap<any, any>>'.
  Type '() => { version: { type: graphql.GraphQLScalarType; }; timestamp: { type: GraphQLScalarType; }; }' is not assignable to type '() => GraphQLFieldConfigMap<any, any>'.
    Type '{ version: { type: graphql.GraphQLScalarType; }; timestamp: { type: GraphQLScalarType; }; }' is not assignable to type 'GraphQLFieldConfigMap<any, any>'.
      Property 'timestamp' is incompatible with index signature.
        Type '{ type: GraphQLScalarType; }' is not assignable to type 'GraphQLFieldConfig<any, any, { [argName: string]: any; }>'.
          Types of property 'type' are incompatible.
            Type 'GraphQLScalarType' is not assignable to type 'GraphQLOutputType'.
              Type 'GraphQLScalarType' is missing the following properties from type 'GraphQLEnumType': getValues, getValuets(2322)
definition.d.ts(447, 3): The expected type comes from property 'fields' which is declared here on type 'Readonly<GraphQLObjectTypeConfig<any, any>>'
(property) fields: graphql.Thunk<graphql.GraphQLFieldConfigMap<any, any>>

Work-around, however I am not sure this is correct:

    timestamp: { type: BigInt as graphql.GraphQLOutputType },
@graphql graphql locked and limited conversation to collaborators Sep 4, 2021
@saihaj saihaj closed this as completed Sep 4, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants