Invalid variable referenced in @include directive

1.2k views Asked by At

I'll duplicate my issue here hoping that someone may give me a hint to where I'm going wrong.

Here's the schema on GraphCool:

type Reservation implements Node {
  createdAt: DateTime!
    id: ID!@isUnique
  updatedAt: DateTime!
    user: User @relation(name: "UserReservations")
}

type User implements Node {
  createdAt: DateTime!
    id: ID!@isUnique
  updatedAt: DateTime!
    reservations: [Reservation!] !@relation(name: "UserReservations")
}

Here's a fragment in my Angular code:

fragment reservation on Reservation {
  id,
  user @include(
    if :$is_admin) {
    id
  }
}

Here's my GraphQL query:

mutation($id: ID!, $is_admin: Boolean = true) {
  createReservation(userId: $id) {
    ...reservation
  }
}
$ {
  RESERVATION_FRAGMENT.reservation
}

Calling the above mutation using apollo.watchQuery executes successfully on GraphCool, but the client produces the following error:

Error: Invalid variable referenced in @include directive.
at directives.js: 42
at Array.some( < anonymous > )
at Object.shouldInclude(directives.js: 20)
at graphql.js: 27
at Array.forEach( < anonymous > )
at executeSelectionSet(graphql.js: 26)
at graphql.js: 55
at Array.forEach( < anonymous > )
at executeSelectionSet(graphql.js: 26)
at graphql.js: 94

0

There are 0 answers