How to Query in GraphQL
Who's this for ?- You need to learn how to query graphQL fast, maybe because your new project or prospective job needs you to.- You are comfortable with traditional rest APIs but can't get into graphQL.- You want Python/Javascript implementation examples.- You are curios about GraphQL.NOTE: This is not the right tutorial if you want to write or serve graphs via an API since I won't be covering that aspect, although I think it helps if you understand how to consume graphs first and some general theory, so this will also help you.
What is it ?
Big picture there’s data in a database somewhere and it can be made public/exposed via an API, traditionally you would be given an endpoint and syntax to query it via REST, something like api.yummysnacks/list_snacks
, then you use some javascript or python library to query it and you get a response, usually in JSON {snacks: {cupcake,cookie,icecream}}
you then use this information to do something useful like display it on a site or app’s front end.
GraphQL is simply another way to get this information ( a query language ), you are still given an API endpoint, something like…