Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/457.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 创建多变量GraphQL查询_Javascript_Graphql_Graphql Js - Fatal编程技术网

Javascript 创建多变量GraphQL查询

Javascript 创建多变量GraphQL查询,javascript,graphql,graphql-js,Javascript,Graphql,Graphql Js,我一直在阅读和尝试很多东西,但只使用cURL作为工具。是否有其他方法针对GraphQL端点运行测试 所以我的问题是一个带有多个变量的变异查询。这是我的谢玛的一部分: type mutation { oneComponentTypeCollected(userID: String!, password: String!, pageID: Int!, Components: ComponentsInput!): Page } type Components { ComponentTy

我一直在阅读和尝试很多东西,但只使用cURL作为工具。是否有其他方法针对GraphQL端点运行测试

所以我的问题是一个带有多个变量的变异查询。这是我的谢玛的一部分:

type mutation {
  oneComponentTypeCollected(userID: String!, password: String!, pageID: Int!,
    Components: ComponentsInput!): Page
}
type Components {
  ComponentType: ComponentType!
    required: Int!
    collected: Int!
}
type ComponentsInput {
  id: String!
    collected: Int!
}
type Page {
  id: Int!
}
如何调用查询oneComponentCollected? 需要将收集的值设置为组件“inkpad_blue”的1

我尝试了以下方法:

变量语法:

{"query":"mutation($input:ComponentsInput!) {oneComponentTypeCollected(userID: \"asd\", password: \"asd\", pageID: 1, input:$input){id}}","variables":{"input":{"id":"Inkpad_blue","collected":1}}} 
作为纯字符串:

mutation($input:ComponentsInput!) {oneComponentTypeCollected(userID: "asd", password: "asd", pageID: 1, input:$input){id}}

两者都会导致500个HTTP错误。

我认为你的变异应该是这样的

mutation{oneComponentTypeCollected(userID: "asd", password: "asd", pageID: 1, Components:{"id": "Inkpad_blue","collected": 1}){id}}
在你的graphiql中试试这个