In this video, Emmanuel Henri goes over the basics of GraphiQL, the tool that comes with GraphQL. He goes over the docs that come with the tool, as well as a few examples of queries with the current data.
- [Instructor] GraphiQL is a tool the Facebook's team built to allow GraphiQL developers to test queries and mutations without using any front end code. As we'll see in a second, it's great to test your data and see the expectations of a query before we actually code it on your front end application. So when you go into GraphiQL, there's a little arrow on the right called Docs. Click on it. And what basically Docs allow you to do is understand what type of queries you can do. So right now we could do a query and that query we could ask for a friend and then they would expect to return a friend with an ID, first name, last name, gender, language, email.
So that tool is very very useful and I'll keep it open as we continue working on our application so you can see how it changes as we change our schema or types and so on so forth. But this is the best way to understand what can I ask here, what kind of queries and when we add a mutations we're going to see mutations here and so on so forth. Another really good trick is if you want to do quick queries you can look into the history of queries that you've done in the past and simply repeat, run it again and do the hello, let the hello one work and you can go back to your friend query and run it.
The other really useful tool is when GraphiQL is not turned on, so if you go back into your code on the server and you turn that off to false, let's go ahead and do that. Save. Stop your server control c and start it again. So now that we have turned our GraphiQL off, if you refresh your page or call for that URL again you'll get an error. So I always go to GraphiQL when building my schemas and resolvers to make sure everything works.
So let's make sure we turn it on again. Stop your server, control c, put GraphiQL to true, save and start your server again and it's back like so. So leave it on and we'll continue. So as we build our app, check GraphiQL's documentation whenever you're not sure on the type of queries and mutations you can call.
- Setting up GraphQL
- Running queries
- Updating schema and solvers
- Adding data
- Adding Relay entry components
- Coding GraphQL fragments