(Day 76 of 100) GraphQL & Graphene Cheatsheet

Dongyob (Eric)
2 min readApr 1, 2019

1. Helpful Resources

2. CRUD (Crete, Read, Update and Delete) equivalents in GraphQL

  • Query is euqivalent to R
  • Mutation is equivalent to CUD

3. CamelCase vs snake_case

4. Query (Read data)

Outcome of Query request when the above code is ran

5. Mutation (Create, Update and Delete data)

Running the mutation code returns the user created.

6. Dynamic Variables (for both mutation and query)

username in above code is dynamic

7. Info (and context)

User can supply graphene information via context through query/mutation request, which then, is utilized by graphene to manipulate the result back to the end user

8. Self

self gives an access to its own class’ field values

9. Graphiql documentation to search all possible queries & mutation

Clicking on the doc highlighted in yellow will show you all available queries and mutations in that application.

10. GraphiQL: mutation in action (example sandbox)

Their schema is illustrated as above. Let’s execute createBaby mutation. Exclamation means it is required. The document shows that createBaby mutation needs babyInfo passed in and should have output of Baby, where baby contains name and votes.
Lefthand is what we executed per schema and righthand is what we get in return

11. Graphene Example Walkthrough (w/ Q search and get_user_model)

12. Insomnia

Graphiql does not support passing values through http headers ie)jwt token. But Insomnia does:

In Insomnia, create new request -> Choose GraphQL Query->provide endpoint (ie: http://localhost:8000/graphql/) ->go to header and configure as shown below to pass header (ie jwt)

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response