Skip to content

Commit

Permalink
fix(docs): Add Yoga example of fragments usage
Browse files Browse the repository at this point in the history
Addresses maticzav#150
  • Loading branch information
maticzav committed Sep 15, 2018
1 parent eb333b8 commit 4268a77
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ coverage
*.log*
.DS_Store
.vscode
.history
.nyc_output
package-lock.json
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,37 @@ const permissions = shield(
whitelist: true,
},
)

// GraphQL Yoga

const server = new GraphQLServer({
typeDefs: './src/schema.graphql',
resolvers,
middlewares: [permissions],
context: ({
request,
response,
fragmentReplacements: middlewareFragmentReplacements,
}) => {
return {
request,
response,
db: new Prisma({
fragmentReplacements: [
...middlewareFragmentReplacements,
...resolverFragmentReplacements,
],
endpoint: process.env.PRISMA_ENDPOINT,
secret: process.env.PRISMA_SECRET,
debug: true,
}),
}
},
})

// GraphQL Middleware

const { schema, fragmentReplacements } = applyMiddleware(schema, permissions)
```

### `Whitelisting vs Blacklisting`
Expand Down

0 comments on commit 4268a77

Please sign in to comment.