Describe the bug
When upgrading from 1.14 to 1.15, an error is thrown that types (which I know to be scalars) are not defined, when they are defined as scalar Date (example) at the top of the schema.
To Reproduce
Steps to reproduce the behavior:
Reproducing issue: https://codesandbox.io/s/stoic-silence-2r2k5?file=/package.json
Same code working with 1.14: https://codesandbox.io/s/frosty-ellis-5u03j?file=/package.json
It looks like this has to do with imports, where schema imports a component, and that component uses a scalar type defined in the schema. maybe that's a circular dependency, but it worked in 1.14.
@xdumaine Could you share a reproduction using CodeSandbox or as a GitHub repo?
@ardatan updated steps to reproduce with demos of 1.14 and 1.15
I'm actually getting a ton of errors about missing types that worked before (maybe implicitly as a bug) that no longer work. As I work through the ones from imports, I'm even getting some that don't involve imports. Ex:
type Palette {
s50: String!
s100: String!
s200: String!
s300: String!
s400: String!
s500: String!
s600: String!
s700: String!
s800: String!
s900: String!
light: String!
main: String!
dark: String!
contrastText: String!
}
type AccountBranding {
# A URL pointing at a 24x24 icon for the account
icon24: String
# A URL pointing at a 120x120 icon for the account
icon120: String
primaryPalette: Palette
}
Throws an error Type "Palette" not found in document.
Error: Type "Palette" not found in document.
To fix that one ^ I had to change my codegen to include all required schema codegen files. Just having the root schema with imports wasn't sufficient.
Thank you very much for the reproduction! We'll take a look soon.
@xdumaine this seems like something that shouldn't work before.
You have the following structure:
- schema.graphql (declares Date)
- components/user.graphql (uses Date)
But, this should be:
- schema.graphql (import Use)
- components/user.graphql (import Date)
- components/date.graphql (declares Date)
@ardatan i tried to update the structure and move the scalar, but it still doesn't work, can you please take a look? https://codesandbox.io/s/dank-forest-ub86g?file=/schema.graphql
UPDATE: @ardatan found the cause for that https://github.com/ardatan/graphql-tools/blob/master/packages/import/src/index.ts#L116
@dotansimha This has been fixed in latest GraphQL Tools. So it is available in latest codegen
Most helpful comment
@dotansimha This has been fixed in latest GraphQL Tools. So it is available in latest codegen