-
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
@graphiql/plugin-utils
& docs, redo #3328
#3346
base: main
Are you sure you want to change the base?
Conversation
|
The latest changes of this PR are available as canary in npm (based on the declared
|
4e27388
to
2a121a9
Compare
@graphiql/plugin-utils
& docs, redo #3328 off main@graphiql/plugin-utils
& docs, redo #3328 off simplify-build
@graphiql/plugin-utils
& docs, redo #3328 off simplify-build
@graphiql/plugin-utils
& docs, redo #3328 against simplify-build
2a896b4
to
6b76b9e
Compare
6b76b9e
to
6fada52
Compare
8ba096a
to
1ef3601
Compare
6fada52
to
d96a33b
Compare
ba3c8e8
to
9ff7e66
Compare
@graphiql/plugin-utils
& docs, redo #3328 against simplify-build
@graphiql/plugin-utils
& docs, redo #3328
48b006a
to
903bec8
Compare
903bec8
to
89197e6
Compare
✅ Deploy Preview for graphiql-test ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
6d53c4d
to
5160d71
Compare
5160d71
to
6a66998
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3346 +/- ##
==========================================
+ Coverage 55.75% 55.85% +0.10%
==========================================
Files 110 110
Lines 5243 5256 +13
Branches 1426 1432 +6
==========================================
+ Hits 2923 2936 +13
Misses 1897 1897
Partials 423 423
|
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.
Minor, human facing.
// TODO: process.env.npm_package_json_path is no longer present in vite. study | ||
try { | ||
// more vite plugins to see how others load the full package.json |
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.
// TODO: process.env.npm_package_json_path is no longer present in vite. study | |
try { | |
// more vite plugins to see how others load the full package.json | |
// TODO: process.env.npm_package_json_path is no longer present in vite. study | |
// more vite plugins to see how others load the full package.json | |
try { |
Developing GraphiQL plugins has always been possible since we introduced them in `graphiql@2`, but the configuration has been a bit tricky | ||
For this, we've created [`@graphiql/plugin-utils`](../../graphiql-plugin-utils/) to help minimize the configuration footprint, set some conventions, and get you up and running |
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.
Developing GraphiQL plugins has always been possible since we introduced them in `graphiql@2`, but the configuration has been a bit tricky | |
For this, we've created [`@graphiql/plugin-utils`](../../graphiql-plugin-utils/) to help minimize the configuration footprint, set some conventions, and get you up and running | |
Developing GraphiQL plugins has always been possible since we introduced them in `graphiql@2`, but the configuration has been a bit tricky. | |
For this, we've created [`@graphiql/plugin-utils`](../../graphiql-plugin-utils/) to help minimize the configuration footprint, set some conventions, and get you up and running. |
1. copy `packages/graphiql-plugin-explorer` to get started | ||
1. customize the package `name`, `description`, and `dependencies`, etc as needed | ||
1. in `vite.config.ts`, change the `umdExportName`. this is how users will load your plugin in the commonly used UMD mode (aka cdn mode, see below) | ||
1. now, begin authoring your plugin in `src/index.tsx` |
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.
1. copy `packages/graphiql-plugin-explorer` to get started | |
1. customize the package `name`, `description`, and `dependencies`, etc as needed | |
1. in `vite.config.ts`, change the `umdExportName`. this is how users will load your plugin in the commonly used UMD mode (aka cdn mode, see below) | |
1. now, begin authoring your plugin in `src/index.tsx` | |
1. Copy `packages/graphiql-plugin-explorer` to get started. | |
1. Customize the package `name`, `description`, and `dependencies`, etc., as needed. | |
1. In `vite.config.ts`, change the `umdExportName`. This is how users will load your plugin in the commonly used UMD mode (a/k/a cdn mode; see below). | |
1. Now, begin authoring your plugin in `src/index.tsx`. |
|
||
## Use the `@graphiql/react` SDK | ||
|
||
you can use the `@graphiql/react` hooks as needed, as your plugin will be able to access all needed contexts |
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.
you can use the `@graphiql/react` hooks as needed, as your plugin will be able to access all needed contexts | |
You can use the `@graphiql/react` hooks as needed, as your plugin will be able to access all needed contexts. |
|
||
## Export a plugin definition | ||
|
||
now, your default export can be the entire plugin definition: |
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.
now, your default export can be the entire plugin definition: | |
Now, your default export can be the entire plugin definition: |
|
||
## Usage: ESM | ||
|
||
Now that it's published to npm or in your monorepo, you can use the plugin in ESM bundler mode easily |
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.
Now that it's published to npm or in your monorepo, you can use the plugin in ESM bundler mode easily | |
Now that it's published to `npm` or in your `monorepo`, you can easily use the plugin in ESM bundler mode. |
}); | ||
``` | ||
|
||
So we use that UMD global in our script: |
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.
So we use that UMD global in our script: | |
We use that UMD global in our script: |
<body> | ||
<div id="graphiql"></div> | ||
</body> | ||
<!-- be sure to include all the other imports, such as react, react-dom and graphiql itself, see /examples/graphiql-cdn --> |
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.
<!-- be sure to include all the other imports, such as react, react-dom and graphiql itself, see /examples/graphiql-cdn --> | |
<!-- Be sure to include all the other imports, such as react, react-dom, and graphiql itself. See /examples/graphiql-cdn. --> |
see #3328 for details & discussion
update:
the canary releases from the previous PR must be being auto-scanned by a vulnerability detection system of some kind? these libraries have no dependents, and we haven't consumed any of these canaries, so I don't understand what's going on here 😆
TODO:
umd
build, currently react jsx runtime is inlined and tries to readprocess
?