我有一个可运行的graphql查询,该查询从后端获取了一堆对象。我正在尝试从查询中排除一个片段,以便也可以在突变中使用它。但是,当我这样做时,我总是收到“错误:模糊的GraphQL文档:包含2个操作”错误。希望能就我做错的事情提供一些意见。
const TICKET_FRAGMENT = gql`{
fragment ticketfragment on TicketNode {
id
title
description
ticketId
created
// Some other fields
}
}`;
const PERSON_TICKETS = gql`
query allTickets ($person_id: ID!) {
allTickets (id: $person_id) {
edges {
node {
...ticketfragment
}
}
}
}
${TICKET_FRAGMENT}
`;
getTickets(personID: string): Observable<ApolloQueryResult<any>> {
return this.apollo.watchQuery<any>({
query: PERSON_TICKETS,
variables: {
person_id: personID
}
}).valueChanges;
}
答案 0 :(得分:0)
尝试一下:
const TICKET_FRAGMENT = gql`
fragment ticketfragment on TicketNode {
id
title
description
ticketId
created
// Some other fields
}
`;