This repository has been archived by the owner on Sep 3, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional scope without space and lowercase
Better aligns with conventions and standards for adding scopes to the hasScope schema directive for authorization.
- Loading branch information
1 parent
98819f0
commit 34125ba
Showing
4 changed files
with
1,009 additions
and
187 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,47 @@ | ||
import { makeAugmentedSchema } from '../../src/index'; | ||
import { ApolloServer } from 'apollo-server'; | ||
import neo4j from 'neo4j-driver'; | ||
|
||
// JWT | ||
// eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJzY29wZXMiOlsicmVhZDp1c2VyIiwiY3JlYXRlOnVzZXIiXX0.jCidMhYKk_0s8aQpXojYwZYz00eIG9lD_DbeXRKj4vA | ||
|
||
// scopes | ||
// "scopes": ["read:user", "create:user"] | ||
|
||
// JWT_SECRET | ||
// oqldBPU1yMXcrTwcha1a9PGi9RHlPVzQ | ||
|
||
const typeDefs = ` | ||
type User { | ||
userId: ID! | ||
name: String | ||
} | ||
type Business { | ||
name: String | ||
} | ||
`; | ||
|
||
const schema = makeAugmentedSchema({ | ||
typeDefs, | ||
config: { auth: { hasScope: true } } | ||
}); | ||
|
||
const driver = neo4j.driver( | ||
'bolt://localhost:7687', | ||
neo4j.auth.basic('neo4j', 'letmein') | ||
); | ||
|
||
const server = new ApolloServer({ | ||
schema, | ||
context: ({ req }) => { | ||
return { | ||
req, | ||
driver | ||
}; | ||
} | ||
}); | ||
|
||
server.listen().then(({ url }) => { | ||
console.log(`GraphQL API ready at ${url}`); | ||
}); |
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
Oops, something went wrong.