Skip to content

Commit

Permalink
Reduce duplication between README.md and view
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Nov 28, 2023
1 parent e1bea43 commit e1796eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,11 @@ You can use that for all kinds of customization.

### Change settings of the GraphiQL UI instance

Add extra settings in the call to `React.createElement(GraphiQL, {})` in the published view:
Add extra props in the call to `React.createElement(GraphiQL, ...)` in the published view.

```js
React.createElement(GraphiQL, {
fetcher: GraphiQL.createFetcher({
url: "{{ $url }}",
subscriptionUrl: "{{ $subscriptionUrl }}",
}),
...,
// See https://github.com/graphql/graphiql/tree/main/packages/graphiql#props for available settings
});
```
Expand All @@ -83,14 +80,11 @@ If you use GraphQL through sessions and CSRF, add the following to the `<head>`
<meta name="csrf-token" content="{{ csrf_token() }}">
```

Modify the GraphQL UI config:
Modify the GraphiQL props as follows:

```diff
React.createElement(GraphiQL, {
fetcher: GraphiQL.createFetcher({
url: '{{ $url }}',
subscriptionUrl: '{{ $subscriptionUrl }}',
}),
...,
+ defaultHeaders: JSON.stringify({
+ 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
+ }),
Expand Down
1 change: 1 addition & 0 deletions views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function GraphiQLWithExplorer() {
onEdit: setQuery,
}),
],
// See https://github.com/graphql/graphiql/tree/main/packages/graphiql#props for available settings
});
}
Expand Down

0 comments on commit e1796eb

Please sign in to comment.