excitement-engineer / graphql-iso-date

A set of RFC 3339 compliant date/time GraphQL scalar types.
MIT License
523 stars 50 forks source link

"Error: Can't find type DateTime." when using internal values for enum #120

Closed AdamTorma closed 4 years ago

AdamTorma commented 4 years ago

In my resolvers, I use something like:

const resolvers = {
  AllowedColor: {
    RED: '#f00',
    GREEN: '#0f0',
    BLUE: '#00f',
  }
};

(example taken from the Apollo Docs)

Unfortunately, adding these internal values results in an error:

C:...\node_modules\graphql-tools\dist\transforms\visitSchema.js:1 Error: Can't find type DateTime.

Everything works fine when using "regular" enums without internal values. On the other hand, the code above works as intended when graphql-iso-date isn't used.

I made this codesandbox, just uncomment the section with the enum resolver to see the problem in action.

Any ideas how to fix this issue?

AdamTorma commented 4 years ago

It seems like the bug is in Apollo / graphql-tools, not in graphql-iso-date, so this issue can be closed!

fierysolid commented 3 years ago

It looks like I was able to resolve this by making sure the names match what is defined in the graphql-iso-date Scalar files:

resolvers:

DateTime: GraphQLDateTime
Date: GraphQLDate
Time: GraphQLTime

schema:

scalar DateTime
scalar Date
scalar Time