Friday, 28 June 2019

GraphQL throwing syntax errors

I am developing the GraphQL Node tutorial, and am up to step 7.

https://www.howtographql.com/graphql-js/7-subscriptions/

I am getting a number of syntax errors from this code in my datamodel.prisma file:

directive @id on FIELD_DEFINITION
directive @unique on FIELD_DEFINITION
directive @createdAt on FIELD_DEFINITION
scalar DateTime

type Link {
    id: ID! @id
    createdAt: DateTime! @createdAt
    description: String!
    url: String!
    postedBy: User
    votes: [Vote!]!
}

type User {
    id: ID! @id
    name: String!
    email: String! @unique
    password: String!
    links: [Link!]!
    votes: [Vote!]!
}

type Vote {
    id: ID! @id
    link: Link!
    user: User!
}

But am still getting 'User' type [@6:1] tried to redefine existing 'User' type [@15:5] and 'Link' type [@24:1] tried to redefine existing 'Link' type [@6:5].

I am also not sure if I am declaring directives or scalars correctly as this is missing from the official tutorial.

Can anyone give any advice on how to sort these issues?



from GraphQL throwing syntax errors

No comments:

Post a Comment