Skip to content
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

chore: bump graphql and graphql-compose major versions #29090

Merged
merged 48 commits into from
Feb 9, 2021
Merged

Conversation

vladar
Copy link
Contributor

@vladar vladar commented Jan 19, 2021

Description

This PR bumps graphql-js major from v14 to v15 and graphql-compose from v6 to v7

Closes #25906

New version of graphql-compose adds type composers added via `createTemp` to schemaComposer. So before the upgrade `schemaComposer.has(typeName)` always returned false for temp types, now it returns true (as the temp composer is already added).
In the new version of graphql-compose the list of actual final types is stored in SchemaComposer itself, not TypeMapper. Also the same composer may have multiple keys
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jan 19, 2021
@vladar vladar removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jan 19, 2021
graphql-compose now adds temporary types to schemaComposer which is unfortunate. The suggested workaround is not to pass schemaComposer to createTemp (so use new schemaComposer under the hood).

That's what we do here but still use the original composer to resolve fields and types.
Those thunks cause stack overflow in graphql-compose. Indicates a bug in graphql-compose that warrants additional investigation.
graphql-compose introduced another behavior change for input type generation and unions. Previously it was ignoring fields of union types, now it throws.

Introduced here: graphql-compose/graphql-compose@b6363be
Another behavior change is that inputTypeComposer.getFields() now returns a map of fields where types are composers while our current code expects types to be types of graphql-js
@vladar vladar changed the title chore: bump graphql major version chore: bump graphql and graphql-compose major versions Jan 21, 2021
@vladar vladar marked this pull request as ready for review February 5, 2021 17:36
@vladar vladar added the topic: GraphQL Related to Gatsby's GraphQL layer label Feb 5, 2021
@vladar vladar added the breaking change If implemented, this proposed work would break functionality for older versions of Gatsby label Feb 8, 2021
Comment on lines -152 to +162
const inputTypeComposer = typeComposer.getInputTypeComposer()
// toInputObjectType() will fail to convert fields of union types, e.g.
// union FooBar = Foo | Bar
// type Baz {
// fooBar: FooBar
// }
// Unfortunately there is no way to just exclude such fields from the input type in graphql-compose v7+,
// so simply replacing them with booleans as the least confusing option :/
const inputTypeComposer = toInputObjectType(typeComposer, {
fallbackType: schemaComposer.getSTC(`Boolean`),
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is confusing. But the best approach to it would be to fix graphql-compose itself (make it allow the old behavior). I'll work on it after higher priority work is done.

Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's dooooo this!!!! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change If implemented, this proposed work would break functionality for older versions of Gatsby topic: GraphQL Related to Gatsby's GraphQL layer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support new graphql major (15)
4 participants