GraphQL gql Syntax Error: Expected Name, found $

GraphQL gql Syntax Error: Expected Name, found $

我正在尝试更新 GraphQL (Angular Apollo) 中的一些数据,但是当我 运行 我的代码显示 GraphQLError: Syntax Error: Expected Name, found " $"

我正在这样做:

const CONFIRM_CITA = gql`
  {
    mutation changeConfirmationStatus ($centroConfirmacion: String!, $estadoConfirmacion: String!, $id: String!) {
      changeConfirmationStatus(centroConfirmacion: $centroConfirmacion, estadoConfirmacion: $estadoConfirmacion, id: $id) {
        id,
        estadoConfirmacion
      }
    }
  }
`
...
export class CitasComponent implements OnInit {
...

update(idCita: string){
  this.apollo.mutate({
          mutation: CONFIRM_CITA,
          variables: {
            centroConfirmacion: "",
            estadoConfirmacion: "Confirmado",
            id: IdCita,
          }
        })
}

为什么会失败?谢谢

gql 后不应该有大括号,见下文:

const CONFIRM_CITA = gql`
    mutation changeConfirmationStatus ($centroConfirmacion: String!, $estadoConfirmacion: String!, $id: String!) {
      changeConfirmationStatus(centroConfirmacion: $centroConfirmacion, estadoConfirmacion: $estadoConfirmacion, id: $id) {
        id,
        estadoConfirmacion
      }
    }
`