-
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
add @graphiql/plugin-explorer
package
#2715
Conversation
🦋 Changeset detectedLatest commit: 5b1104a 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
|
If you add it to the two resources/*build.tsconfig.json files, this project will build esm and cjs on tsc —build and tsc —build —watch. graphiql can take care of bundling everything else. No need to bundle any of the @graphiql projects with vite or rollup or webpack, sorry for introducing that anti-pattern. They are bundled with graphiql’s bundle, so we only need vite in packages/graphiql to replace webpack now |
@acao we have some CSS that we wanna bundle up for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me! Thank you!
This adds a the first official GraphiQL plugin as package, which is the OneGraph Explorer!
The only export of the package is a hook called
useExplorerPlugin
which will return the plugin object that can be passed to theGraphiQL
component. An example of how this works is included in the package README.This PR also proposes a solution of how to use these plugin packages in CDN bundles. The crux here is that we mustn't load
graphql-js
more than once, otherwise we run into the "different realms" problem. The solution has two parts:graphiql
already includesgraphql-js
, so we now set a static propertyGraphiQL.GraphQL
that contains all the exports fromgraphql-js
.graphql
as external and set the global toGraphiQL.GraphQL
, that way the CDN bundle for the plugin won't contain any parts ofgraphql-js
and it will use the module from thegraphiql
CDN bundle.(Note that we do basically the same thing with
@graphiql/react
as we already need to include it in thegraphiql
CDN bundle. That way we don't need to load the same code twice in plugin CDN bundles that need any of the exports from that package.)There is a tiny breaking change hidden here, because we remove the three hooks that we previously directly added as static properties on
GraphiQL
in the CDN bundle. I reckon it's fine as we only added that two days ago, also there is a simply fix to that by just using the hook fromGraphiQL.React.useXYZ
.