Instead of functions, uses a verbose, string based syntax for schemas
Can transform the syntax into many representations if needed
much easier to read
composable
Scalar and Object Types
Describe resources that will be used in queries and mutations
Scalar Types
Built in primitives
String
Int
Float
Boolean
ID
Object Types
Custom shapes with fields that are either scalar types or other object types
Object type fields also describe any arguments and or validations
Types are the target or all requests. Obj of gql is to resolve types
Query and Mutations Types
CRUD on your GraphQL API
Query types describe the different queries your API is capable of
You can define types, but if they aren't named inside the query type, its useless
A querry opration is just a name, with possible arguments that eventualy return a type
A mutation is the same, but with the intent of mutating the DB vs just reading
Queries and Mutations are what will be available to clients with your API.
Think of them as your routes. They're what your API can do
Resolvers
Like controllers, but instead resolve types all the way down. Where you talk to the DB
Responsible for retrieving data
Every query and mutation you have, you must have a resolver that returns the specified type
Types and fields on types often hae resolvers as well
Incoming query dictates what resolvers run and in what order
Creating Resolvers
Return the same shape as described in the schema, or delegate to another resolver
Resolvers take a few args
starting obj (what the parent resolveer returned or starting value from the server)
args (any args fron the incoming request)
context (shared context obj across all resolvers, like the req obj in express)
info (advanced AST of the incoming request) - abstract syntax tree
Interfaces
Inheritable types for your schema
Some types are very similar with the exception of a few fields
You can use an interface as a base type and have other types implement that interface
You then have to use fragments in your request query to conditionally ask for that type specific fields
Unions
Combo type that can be one of many different ty[es that may not relate to each other
Smetimes you want a query to return a possibility of more than just one type. Unions allow you to create a type that is composed of many types where any of them may be fulfilled.