Skip to content

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

@EdwardEddyEd

Description

@EdwardEddyEd

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions