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(gatsby-source-graphql): upgrade to graphql-tools v6 #24158

Merged
merged 6 commits into from Jul 2, 2020

Conversation

yaacovCR
Copy link
Contributor

@yaacovCR yaacovCR commented May 17, 2020

Description

Upgrade dependency graphql-tools to v6

Major change is that in v6, graphql-js objects are considered immutable, hopefully leading to greater interoperability.

Pending release of v6.

Documentation

https://www.graphql-tools.com/

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label May 17, 2020
@blainekasten blainekasten added status: blocked This issue/PR can't be solved at the moment and shouldn't be closed/merged and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels May 18, 2020
@blainekasten blainekasten requested a review from vladar May 18, 2020 17:42
@blainekasten
Copy link
Contributor

Marking this as blocked until v6 is released, also assigning to @vladar who leads most of our graphql effort.

@vladar vladar self-assigned this May 18, 2020
@yaacovCR yaacovCR marked this pull request as ready for review May 21, 2020 14:16
@yaacovCR yaacovCR requested a review from a team as a code owner May 21, 2020 14:16
@blainekasten blainekasten added status: needs core review Currently awaiting review from Core team member and removed status: blocked This issue/PR can't be solved at the moment and shouldn't be closed/merged labels May 21, 2020
Copy link
Contributor

@vladar vladar left a comment

Choose a reason for hiding this comment

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

@yaacovCR Congrats with the v6 release of graphql-tools! 🎉

The PR looks good to me but I need to try it locally before merging (and also check out the changelog of graphql-tools). I will get back to you when I have a chance to do this. And thanks a lot for your help with migration to v6! 💜

@yaacovCR
Copy link
Contributor Author

Happy to help,

I also noticed you seem to have to work around a few issues in GraphQL compose when you are rebuilding a schema...

I wonder if using some of our utilities functions would help you out with that, as you can see from above, mapSchema let's you start from any initial schema and do the composition on built graphql schema objects.

Not really sure why you are rebuilding, what has changed and what hasn't and whether this would help you but just figured I would flag it.

We built some helper functions that can add types and modify object fields using the above approach, but there are additional possibilities that might help you as well.

@yaacovCR yaacovCR requested a review from a team as a code owner June 9, 2020 13:42
@yaacovCR
Copy link
Contributor Author

yaacovCR commented Jun 9, 2020

Upgrade to latest graphql-tools version, v6.0.9, also switched gatsby-recipes to use scoped packages for smaller bundle size.

Fix of interest: ardatan/graphql-tools#1572

@yaacovCR
Copy link
Contributor Author

yaacovCR commented Jun 9, 2020

Note that I did not change the metadata recipe to use the newer functional directive approach. We are hoping to still provide backwards compatibility with the current approach.

Also, populating metadata is still an unresolved issue overall, with the guidance from graphql-js to use the extensions field for graphql objects, but no built-in approach to populating it. I think that the eventual solution (possibly built on something like graphql-tools's functional directive approach?) should really be in graphql-js, and it seems counterproductive to iterate through multiple interim solutions.

@vladar
Copy link
Contributor

vladar commented Jun 10, 2020

Sorry for the delay with this. We are having a company event this week, so I will revisit it the next week.

Also can you please post a separate PR for gatsby-recipes changes? The reason is that we're using conventional commits and ideally, single PR should affect a single package.

@vladar vladar changed the title upgrade to graphql-tools v6 chore(gatsby-source-graphql): upgrade to graphql-tools v6 Jun 10, 2020
@yaacovCR
Copy link
Contributor Author

Will do

@yaacovCR yaacovCR force-pushed the graphql-tools-v6 branch 2 times, most recently from 1b709cd to a6dd659 Compare June 11, 2020 06:02
@yaacovCR
Copy link
Contributor Author

@johno

@yaacovCR
Copy link
Contributor Author

yaacovCR commented Jul 1, 2020

Hmmm, looks like Gatsby recipes changes made it, but not this one...

@yaacovCR
Copy link
Contributor Author

yaacovCR commented Jul 1, 2020

@vladar @johno let me know if I messed up something....

@vladar
Copy link
Contributor

vladar commented Jul 1, 2020

Can you rebase or merge master? I am going to test it locally first thing tomorrow and then we can merge if everything is fine!

Copy link
Contributor

@vladar vladar left a comment

Choose a reason for hiding this comment

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

Sorry for the delay, just got to testing. It fails for me with an error:

TypeError: executor is not a function

Here:

introspectionSchema = await introspectSchema(link)

I belive it's because introspectSchema expects executor vs link now:

export async function introspectSchema(executor: AsyncExecutor, context?: Record<string, any>): Promise<GraphQLSchema> 

@vladar
Copy link
Contributor

vladar commented Jul 2, 2020

Actually the fix was a quick one (just pushed). Trying to resolve conflicts and make the tests pass, which is harder :)

Copy link
Contributor

@vladar vladar left a comment

Choose a reason for hiding this comment

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

Ok, works as expected after the quick fix. Let's merge this 🚢

Will publish it as a new minor

@vladar vladar added the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label Jul 2, 2020
@gatsbybot gatsbybot merged commit c424dc1 into gatsbyjs:master Jul 2, 2020
@vladar
Copy link
Contributor

vladar commented Jul 2, 2020

Published in gatsby-source-graphql@2.6.0

danabrit pushed a commit that referenced this pull request Jul 2, 2020
* upgrade gatsby-source-graphql to graphql-tools v6

* Update yarn.lock

* fix broken introspectSchema call

* Update yarn.lock (again)

Co-authored-by: Vladimir Razuvaev <vladimir.razuvaev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes status: needs core review Currently awaiting review from Core team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants