Add shouldPersistHeaders = true to GraphiQL options #257
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR comes with a caveat. Question is if this option should be set to true by default because of security reasons (this is also the reason why it is not enabled by default).
This is also related to #136 enabling the GraphiQL header editor which is already merged to provide e.g. authorization headers like an API key.
This is also my use case, my GraphQL server requires an API key which I can provide via headers editor and it works as expected, thus so far so good.
But without the
shouldPersistHeaders = true
option headers are not persisted so on reload (or just opening GraphiQL page) the headers editor is empty.Of course no problem to add the header again manually, but the consequence is that when GraphiQL is loaded it will fire an initial request to load the Schema which is used for displaying the docs and auto-completion...
As headers are currently not stored that first request to get the schema details fails and no documentation and auto-completion available unfortunately, making the GraphiQL interface far from optimal...
As I said it is questionable if this value should be set by default.
Alternative could be to have some
spring.graphql.graphiql.options
orspring.graphql.graphiql.additional-options
property to add custom options to the GraphiQL interface. Something like:Footnote: I wonder only having
headerEditorEnabled = true
and notshouldPersistHeaders
is really useful, as I think most will use it for authorization, and that is needed on GraphQL request to get schema as well.