Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions __tests__/__snapshots__/hasRole.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`getDirectiveDeclaration should be defined 1`] = `
GraphQLDirective {
"args": Array [
Object {
Object {
"args": Object {
"role": Object {
"astNode": undefined,
"defaultValue": undefined,
"description": null,
"name": "role",
"description": undefined,
"extensions": undefined,
"type": "String",
},
],
},
"astNode": undefined,
"description": undefined,
"extensions": undefined,
"isRepeatable": false,
"locations": Array [
"FIELD_DEFINITION",
],
Expand Down
6 changes: 4 additions & 2 deletions __tests__/__snapshots__/isAuthenticated.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`getDirectiveDeclaration should be defined 1`] = `
GraphQLDirective {
"args": Array [],
Object {
"args": Object {},
"astNode": undefined,
"description": undefined,
"extensions": undefined,
"isRepeatable": false,
"locations": Array [
"FIELD_DEFINITION",
],
Expand Down
2 changes: 1 addition & 1 deletion __tests__/hasRole.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ beforeAll(() => {
});

test('getDirectiveDeclaration should be defined', () => {
expect(AuthDirective().hasRole.getDirectiveDeclaration()).toMatchSnapshot();
expect(AuthDirective().hasRole.getDirectiveDeclaration().toConfig()).toMatchSnapshot();
});

test('if throw error if no role inside token payload', () =>
Expand Down
2 changes: 1 addition & 1 deletion __tests__/isAuthenticated.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ beforeAll(() => {

test('getDirectiveDeclaration should be defined', () => {
expect(
AuthDirective().isAuthenticated.getDirectiveDeclaration()
AuthDirective().isAuthenticated.getDirectiveDeclaration().toConfig()
).toMatchSnapshot();
});

Expand Down
3 changes: 3 additions & 0 deletions example/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { AuthDirective } from '../src/index';
import { makeExecutableSchema } from 'graphql-tools';

const typeDefs = gql`
directive @isAuthenticated on FIELD_DEFINITION
directive @hasRole(role: String) on FIELD_DEFINITION

type User {
id: ID!
username: String!
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,19 @@
"@babel/preset-env": "^7.1.0",
"@babel/preset-typescript": "^7.1.0",
"@babel/register": "^7.0.0",
"@types/graphql": "^14.0.3",
"@types/jsonwebtoken": "^7.2.8",
"apollo-server-express": "^2.0.0",
"body-parser": "^1.18.3",
"eslint": "^5.2.0",
"eslint-config-callstack-io": "^1.1.2",
"express": "^4.16.4",
"graphql": "^0.13.2",
"graphql-tools": "^3.0.5",
"jest": "^23.6.0",
"graphql": "^15.0.0",
"graphql-tools": "^5.0.0",
"jest": "^25.4.0",
"mock-express-request": "^0.2.2",
"nock": "^10.0.2",
"nodemon": "^1.18.7",
"ts-jest": "^23.10.4",
"ts-jest": "^25.4.0",
"typescript": "^3.1.6"
},
"dependencies": {
Expand Down
Loading