Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run a mutation? Add example to Readme #72

Closed
extrajordanary opened this issue Dec 16, 2015 · 8 comments
Closed

How to run a mutation? Add example to Readme #72

extrajordanary opened this issue Dec 16, 2015 · 8 comments

Comments

@extrajordanary
Copy link

I can query just fine, but I'm having a hard time figuring out the correct format for mutations. Here's a screenshot of what I'm playing with:

https://www.dropbox.com/s/4g0r4ii3z3u7zir/Screenshot%202015-12-16%2010.58.25.png?dl=0

Basically I'm just not sure of the correct format for setting up the ChangeCohortInput but I remember seeing someone else do it by making that as a variable in the Query Variables section.

@tinnou
Copy link

tinnou commented Jan 11, 2016

Let say your ChangeCohortInput has the fields clientMutationId and title.

Your mutation would look like:

mutation example($cohort: ChangeCohortInput!){
  change_cohort(input: $cohort) {
    user {
      cohort {
        title
      }
    }
  }
}

and variables

{
  "cohort": {
    "clientMutationId": "random",
    "title": "New cohort title"
  }
}

@asiandrummer
Copy link
Contributor

Thanks for the answer @tinnou. I do feel like the example for mutation operation better belongs to GraphQL Specifications Document, as it already explains the correct specifications, requirements, and examples for running a mutation operation.

@holmesal
Copy link

holmesal commented Feb 9, 2016

@asiandrummer I think a lot of people (like me, 5 minutes in the past 😁) are going to land on the graphiql README looking for precisely the example above, and while the graphql specification document technically has the info you need, it's a lot to parse/search.

Might be worth adding an example for first-timers?

@extrajordanary
Copy link
Author

@asiandrummer I agree with @holmesal, the GraphQL Specifications Document is extremely dense. I would never be able to find the info needed within it if I didn't already know what the answer is so that I can ctrl-f the page for $.

the screenshot on the readme alone is already a 100% improvement, but even a simple list of links to the most relevant parts of the GraphQL Specifications Document would be another good and not-too-painful improvement for users

@asiandrummer
Copy link
Contributor

Per lots of requests for the examples in README (simple query examples && GraphiQL component customizations), I'm working on adding/improving the README. Please stay tuned for upcoming updates :D

@extrajordanary
Copy link
Author

@asiandrummer greatly appreciate it, really do love using GraphiQL :)

@asiandrummer
Copy link
Contributor

Alright, I've tried adding some examples to README - go check it out!
I'll close this issue for now, but if you have any other suggestions, feel free to open another issue or reopen this one.

@sarink
Copy link

sarink commented Oct 9, 2018

If you're like me, you simply missed the sneaky "variables" input box (bottom left corner):

screen shot 2018-10-09 at 5 08 59 pm

screen shot 2018-10-09 at 5 09 10 pm

acao pushed a commit to acao/graphiql that referenced this issue Jun 5, 2019
…ransform-es2015-duplicate-keys-6.22.0

Update babel-plugin-transform-es2015-duplicate-keys to version 6.22.0 🚀
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants