-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(jwt/introspection): ability to disable introspection based on JWT…
… result
- Loading branch information
Showing
8 changed files
with
210 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@graphql-yoga/plugin-jwt': patch | ||
--- | ||
|
||
Ensure the JWT context has been added before any GraphQL Execution hooks when the plugin is used via Yoga |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
'@graphql-yoga/plugin-disable-introspection': minor | ||
--- | ||
|
||
Expose the server context as the second parameter, so introspection can be disabled based on the | ||
context | ||
|
||
```ts "Disabling GraphQL schema introspection based on the context" {7} | ||
import { createYoga } from 'graphql-yoga' | ||
import { useDisableIntrospection } from '@graphql-yoga/plugin-disable-introspection' | ||
|
||
// Provide your schema | ||
const yoga = createYoga({ | ||
graphiql: false, | ||
plugins: [ | ||
useDisableIntrospection({ | ||
isDisabled: (_req, ctx) => !ctx.jwt, | ||
}) | ||
] | ||
}) | ||
|
||
const server = createServer(yoga) | ||
server.listen(4000, () => { | ||
console.info('Server is running on http://localhost:4000/graphql') | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters