我将在这里复制我的问题,希望有人可以提示我哪里出错了。
这是 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")
}
这是我的 Angular 代码中的一个片段:
fragment reservation on Reservation {
id,
user @include(
if :$is_admin) {
id
}
}
这是我的 GraphQL 查询:
mutation($id: ID!, $is_admin: Boolean = true) {
createReservation(userId: $id) {
...reservation
}
}
$ {
RESERVATION_FRAGMENT.reservation
}
在 GraphCool 上使用执行成功调用上述突变apollo.watchQuery
,但客户端产生以下错误:
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