I was following the `Adding Authentication` tutori...
# orm-help
s
I was following the
Adding Authentication
tutorial (https://www.howtographql.com/graphql-js/6-authentication/) but I am getting this error:
Copy code
Error: Directive `unique`: Couldn't find type `unique` in any of the schemas.
Has anyone seen this before?
n
looks like the
@unique
directive from your datamodel somehow ended up in your schema, which should never be the case
browsing the tutorial, I don't find that error there, so it might be a wrong copy paste from you?
search for
@unique
in your project 🙂
s
Ah. I had copied my User modal over and left
@unique
on there. Thanks 🙂
n
user from datamodel:
Copy code
type User {
  id: ID! @unique
  name: String!
  email: String! @unique
  password: String!
  links: [Link!]!
}
user in schema:
Copy code
type User {
  id: ID!
  name: String!
  email: String!
  links: [Link!]!
}
note that
password
is left out deliberately
that's removes the
password
field when querying the
User
type anywhere in your resolver tree
s
Yeah I saw the password part. Is there a justification for removing the @unique stuff, other than just leaving that to the main GQL server?
n
it has no meaning in this context
@unique
is a directive that is specific to Prisma datamodels. It tells the Prisma connector to add a unique index to the respective column.
s
Ahh. That makes sense.
What about
@default
and
@relation
?
n
same story, but with different effects 🙂
s
Cool. I re-ran the server while I asked that question and it gave me the same error 😄
Thanks for your help.
n
you're welcome! 🙂