【发布时间】:2022-08-24 17:38:07
【问题描述】:
我正在使用 Graphql 开发一个角度应用程序,邮递员的突变操作工作正常, 但是当我尝试在角度中调用相同的内容时,它会引发错误
GraphQL 请求:2:21 1 | 2 |突变 createHero(item: {$id : ID!, $publisher : String!, $characters : String!, $superhero :String!}){
| ^ 3 | createHero(项目:{id:$id,发布者: $publisher,人物:$characters,超级英雄:$superhero}) GraphQLError:语法错误:应为 \"$\",找到名称 \"item\"。这是工作请求
mutation{ createHero (item:{ id:\"test1\", alter_ego:\"hero\", first_appearance:\"cosmos\", publisher:\"azure\", superhero:\"test\"}) { id superhero publisher characters alter_ego first_appearance } }这是Angular应用程序上的代码,
const post_SaveHero = gql` mutation createHero(item: {$id : ID!, $publisher : String!, $characters : String!, $superhero :String!}){ createHero(item: {id: $id, publisher : $publisher , characters : $characters , superhero : $superhero} ) { superhero } }`; addHero(hero: Hero) { return this.apollo.mutate({ mutation: post_SaveHero, variables: { $publisher: hero.publisher, $characters: hero.characters, $superhero: hero.superhero, $id : hero.id, $alter_ego : hero.alter_ego, $first_appearance : hero.first_appearance, } }); }这里有什么问题?请帮忙。
标签: angular graphql apollo-client