-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat(graphiql): pass introspection data to schema
prop
#2574
Conversation
🦋 Changeset detectedLatest commit: 397cbfe The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest changes of this PR are available as canary in npm (based on the declared
|
Codecov Report
@@ Coverage Diff @@
## main #2574 +/- ##
==========================================
+ Coverage 65.70% 69.46% +3.75%
==========================================
Files 85 71 -14
Lines 5106 4156 -950
Branches 1631 1376 -255
==========================================
- Hits 3355 2887 -468
+ Misses 1747 1264 -483
- Partials 4 5 +1
Continue to review full report at Codecov.
|
I’m all for it! What do you think of |
I thought about this but decided against it for two reasons:
|
Do you have any example code of how this is actually used? I can't quite figure that part out 😅 I think this'd allow me to use a static JSON representation of my GraphQL schema to have GraphiQL load automatically, but I'm not 100% sure how to provide the GraphiQL component with the right object. |
Hey @connorshea 👋 the object you can pass here is the data returned from a "standard" introspection query (you can check the |
yup, that helps! thanks |
This is a small QoL improvement: The
schema
prop now also accepts introspection data as an alternative to aGraphQLSchema
instance. Also, this fixes a bug where the schema was not updated after rerunning introspection.We had a use-case for this feature at Stellate: We store introspection data for different endpoints, and we want to use this to render GraphiQL on the client without running introspection (because this is likely to be disabled for lots of production APIs). We'd now have to add
graphql
as first-class dependency just to callbuildClientSchema
once. With this tiny change theSchemaContextProvider
does that for us, which is a lot nicer DX.💡 Reviewing with whitespace turned off halves the LOCs!