GraphQL Learning materials
There are 3 major types of operations we can perform.
query {
hello
courseInstructor
me {
name
}
}
mutation - to transform some data in a way we want
subscription - watch data for changes
When using graphql with node.js we can choose between different types of servers:
GraphQL playground is constantly sending requests to our server to have updated schema. We can change the settings if needed by clicking the icon top-right corner.
Data ending with exclamation mark ‘!’ means it is required and can not be null
input in type definitions are not necessary but good to use and provide them as function arguments because this way the code is easier to read and we can reuse the inputs in other function arguments
With ctrl + space in the playground you can expand the list with available keys.
The point of using enum is if we want to enforce specific options only.
For example if we have String! it could be any string and what if we want just a few specific options like let’s say: ON, OFF, SLEEP
The other benefit is if we want strings or booleans, if we set string then we will not have the boolean. With enum we can specify some string and boolean values that we want to accept for example
GraphQL is working with .json objects and in case we need to work with files a solution is to use rest endpoint just for the file. Our API will basically handle all the json data with graphql and separate rest routes for files.