File tree Expand file tree Collapse file tree 3 files changed +19
-11
lines changed
packages/graphiql-plugin-explorer/examples Expand file tree Collapse file tree 3 files changed +19
-11
lines changed Original file line number Diff line number Diff line change 1
1
# GraphiQL CDN Example
2
2
3
- This example uses the CDN bundles to show the most simple example possible. It
4
- uses the latest version published on npm, via unpkg
3
+ This example uses the CDN bundles to show a simple graphiql example, with explorer plugin.
4
+
5
+ It uses the latest version published on npm, via unpkg
5
6
6
7
### Setup
7
8
Original file line number Diff line number Diff line change 37
37
crossorigin
38
38
src ="https://unpkg.com/react-dom@18/umd/react-dom.development.js "
39
39
> </ script >
40
-
40
+ < script
41
+ src ="https://unpkg.com/graphiql/graphiql.min.js "
42
+ type ="application/javascript "
43
+ > </ script >
44
+ < script
45
+ src ="https://unpkg.com/@graphiql/plugin-explorer/dist/index.umd.js "
46
+ crossorigin
47
+ > </ script >
41
48
<!--
42
49
These two files can be found in the npm module, however you may wish to
43
50
copy them directly into your environment, or perhaps include them in your
48
55
49
56
< body >
50
57
< div id ="graphiql "> Loading...</ div >
51
- < script
52
- src ="https://unpkg.com/graphiql/graphiql.min.js "
53
- type ="application/javascript "
54
- > </ script >
55
58
< script >
56
59
const root = ReactDOM . createRoot ( document . getElementById ( 'graphiql' ) ) ;
60
+ const fetcher = GraphiQL . createFetcher ( {
61
+ url : 'https://swapi-graphql.netlify.app/.netlify/functions/index' ,
62
+ headers : { 'X-Example-Header' : 'foo' } ,
63
+ } ) ;
64
+ const explorerPlugin = GraphiQLPluginExplorer . explorerPlugin ( ) ;
57
65
root . render (
58
66
React . createElement ( GraphiQL , {
59
- fetcher : GraphiQL . createFetcher ( {
60
- url : 'https://swapi-graphql.netlify.app/.netlify/functions/index' ,
61
- } ) ,
67
+ fetcher,
62
68
defaultEditorToolsVisibility : true ,
69
+ plugins : [ explorerPlugin ] ,
63
70
} ) ,
64
71
) ;
65
72
</ script >
Original file line number Diff line number Diff line change 47
47
crossorigin ="anonymous "
48
48
> </ script >
49
49
< script
50
- src ="https://unpkg.com/@graphiql/plugin-explorer@0.1.12 /dist/index.umd.js "
50
+ src ="https://unpkg.com/@graphiql/plugin-explorer/dist/index.umd.js "
51
51
integrity ="sha512-Fjas/uSkzvsFjbv4jqU9nt4ulU7LDjiMAXW2YFTYD96NgKS1fhhAsGR4b2k2VaVLsE29aia3vyobAq9TNzusvA== "
52
52
crossorigin ="anonymous "
53
53
> </ script >
You can’t perform that action at this time.
0 commit comments