Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get authentication for 'getUser' query with @isAuth directive #2

Open
EdwardEddyEd opened this issue Jan 20, 2019 · 0 comments

Comments

@EdwardEddyEd
Copy link

When following the tutorial, I was able to execute the 'createUser' mutation successfully, but was unable to continue after the 'getUser' query. I made sure to include the bearer token in the 'HTTP HEADERS' tab at the bottom of the graphql playground. Unfortunately, I was given the following output:

{
  "data": {
    "getUser": null
  },
  "errors": [
    {
      "message": "User not authenticated",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "getUser"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stacktrace": [
            "Error: User not authenticated",
            "    at field.resolve (/Users/edward/Documents/WebFiles/mainDirectory/node_graphql_apollo_template/src/graphql/directives/auth.directive.ts:27:15)",
            "    at field.resolve (/Users/edward/Documents/WebFiles/mainDirectory/node_graphql_apollo_template/node_modules/graphql-extensions/src/index.ts:207:30)",
            "    at resolveFieldValueOrError (/Users/edward/Documents/WebFiles/mainDirectory/node_graphql_apollo_template/node_modules/graphql/execution/execute.js:479:18)",
            "    at resolveField (/Users/edward/Documents/WebFiles/mainDirectory/node_graphql_apollo_template/node_modules/graphql/execution/execute.js:446:16)",
            "    at executeFields (/Users/edward/Documents/WebFiles/mainDirectory/node_graphql_apollo_template/node_modules/graphql/execution/execute.js:293:18)",
            "    at executeOperation (/Users/edward/Documents/WebFiles/mainDirectory/node_graphql_apollo_template/node_modules/graphql/execution/execute.js:237:122)",
            "    at executeImpl (/Users/edward/Documents/WebFiles/mainDirectory/node_graphql_apollo_template/node_modules/graphql/execution/execute.js:85:14)",
            "    at Object.execute (/Users/edward/Documents/WebFiles/mainDirectory/node_graphql_apollo_template/node_modules/graphql/execution/execute.js:62:35)",
            "    at Promise.resolve.then (/Users/edward/Documents/WebFiles/mainDirectory/node_graphql_apollo_template/node_modules/apollo-server-core/src/runQuery.ts:235:23)",
            "    at <anonymous>",
            "    at process._tickDomainCallback (internal/process/next_tick.js:229:7)"
          ]
        }
      }
    }
  ]
}

I tried logging through auth.directive.ts and reading docs about SchemaDirectiveVisitors but couldn't fix the issue. Is there something that I'm missing in trying to resolve this error? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant