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

[FOR DISCUSSION] Expose GQL Union possibilities #2990

Closed
wants to merge 9 commits into from

Conversation

uttrasey
Copy link

Raising a super rough PR to get early feedback.

Following on from the discussion here #2775 I've proposed a new API to allow sites/plugins to manipulate the GQL schema to do cool stuff. In my case I wanted to add a Union type which would allow me to query for 2 types at the same time. This has been achieved (very roughly) over here uttrasey/gatsby-union-demo#2

Assuming a path exists forward I'm keen to hear thoughts if it's possible to make use of some of the awesome stuff available in build-node-connections for filtering, paging, sorting etc.

What do folks think?

@gatsbybot
Copy link
Collaborator

Deploy preview ready!

Built with commit 675afcb

https://deploy-preview-2990--gatsbygram.netlify.com

@gatsbybot
Copy link
Collaborator

Deploy preview ready!

Built with commit 675afcb

https://deploy-preview-2990--using-drupal.netlify.com

@gatsbybot
Copy link
Collaborator

gatsbybot commented Nov 22, 2017

Deploy preview ready!

Built with commit e0ab383

https://deploy-preview-2990--gatsbygram.netlify.com

@gatsbybot
Copy link
Collaborator

gatsbybot commented Nov 22, 2017

Deploy preview ready!

Built with commit e0ab383

https://deploy-preview-2990--using-drupal.netlify.com

@KyleAMathews
Copy link
Contributor

Deploy preview failed.

Built with commit fbaad4e

https://app.netlify.com/sites/using-glamor/deploys/5a1c3fb44c4b935d370b3230

Copy link
Contributor

@KyleAMathews KyleAMathews left a comment

Choose a reason for hiding this comment

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

Super interesting!

This seems like a pretty plausible way to add support for this sort of thing.

Have you looked at Schema stitching yet? We really need support for that to make it easier for people to pull in existing GraphQL schemas. Probably doesn't need to be done in this PR but an additional thing to be considering https://dev-blog.apollodata.com/graphql-schema-stitching-8af23354ac37

* Run after the schema has been created but before it's dispatched allowing you
* to do cool enhancements e.g. union / interface stuff
*/
exports.enhanceSchema = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Per the API specification, this should be setSchemaFields https://www.gatsbyjs.org/docs/api-specification/#operators

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, let's make this createSchemaFields. There's no reason to allow people to override the default fields so we should validate against that.

@KyleAMathews
Copy link
Contributor

@uttrasey you think you'll have time soon to finish this up?

@uttrasey
Copy link
Author

I've not had a chance to finish the site implementation and think it should wait for that. It's going to be a push for this year. We could close and re-open next year?

@KyleAMathews
Copy link
Contributor

Nah, not a big deal. We can leave it open.

@KyleAMathews
Copy link
Contributor

Hey, closing out old PRs. Would love to see you or someone else pick this up and carry it to the finish line!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants