user1911283
user1911283

Reputation: 111

Creating multi variable GraphQL query

I've been reading and trying alot of Stuff, but only using cURL as tools. Are there other ways run tests against an GraphQL endpoint?

So my problem is an mutation query with serveral variables. Here is part of my Shema:

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!
}

How do i call query the oneComponentCollected mutation? What is expected is to set the collected value to 1 of the Component "inkpad_blue"

I tried the Following:

Variable syntax:

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

as pure String:

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

Both result in 500 HTTP errors.

Upvotes: 0

Views: 264

Answers (1)

Seena V P
Seena V P

Reputation: 994

I think your mutation should go like this

mutation{oneComponentTypeCollected(userID: "asd", password: "asd", pageID: 1, Components:{"id": "Inkpad_blue","collected": 1}){id}}

Try this in your graphiql

Upvotes: 1

Related Questions