Fork me on GitHub
#graphql
<
2017-10-03
>
guy16:10:40

Hi i've got a newbie question so apologies in advance. When you sent a mutation which has a input-object inside of it. Do you just reference the input-object as $thing inside of the json you send from the client? If that makes sense?

guy16:10:54

I'm just trying to understand the shape of the data when you send it in JSON format

guy16:10:57

For example you have : http://graphql.org/learn/schema/#input-types

mutation CreateReviewForEpisode($ep: Episode!, $review: ReviewInput!) {
  createReview(episode: $ep, review: $review) {
    stars
    commentary
  }
}

{
  "ep": "JEDI",
  "review": {
    "stars": 5,
    "commentary": "This is a great movie!"
  }
}

guy16:10:50

{
  "query": "...",
  "operationName": "...",
  "variables": { "myVariable": "someValue", ... }
}

guy16:10:23

ok embarrassingly i think i figured it out

guy16:10:42

I think it would look like this

{
   "query":"createReview($ep, $review)",
   "operationName":"",
   "variables":{
      "ep":"JEDI",
      "review":{
         "stars":5,
         "commentary":"This is a great movie!"
      }
   }
}

hlship16:10:56

{
   "query":"query ($ep : Episode, $review: ReviewInput) { createReview(episode: $ep,  review: $review) { xyz }}",
   "operationName":"",
   "variables":{
      "ep":"JEDI",
      "review":{
         "stars":5,
         "commentary":"This is a great movie!"
      }
   }
}

hlship16:10:45

Variables are part of a GraphQL query (not the schema). To use query parameters, you must define them first. You can then match the parameters to the arguments of your operation and fields as if they were literals.

guy16:10:45

thanks @hlship! got it