saihaj / graphql-ts-node-advanced-tutorial

WIP tutorial
0 stars 1 forks source link

`@skipAuth` not working on nested objects? #3

Closed saihaj closed 2 years ago

saihaj commented 3 years ago
directive @skipAuth on FIELD_DEFINITION

type Query {
  info: String! @skipAuth
  me: User! @skipAuth
}

type Mutation {
  login(email: String!, password: String!): AuthPayload @skipAuth
}

type AuthPayload {
  token: String
  user: User
}

type User {
  id: ID!
  name: String!
  email: String!
  links: [Link!]!
}

So if I try to get info or me everything is working as i expect. But when I run login mutation to get token I get unauthenticated error on

"path": [
  "login",
  "token"
]
n1ru4l commented 2 years ago

image

Makes sense, because the @skipAuth is not applied on the fields that are selected by the operation?

saihaj commented 2 years ago

If I add to type shouldn't that apply to all the types?

saihaj commented 2 years ago

wait nvm FIELD_DEFINITION