graphQL 1
https://graphql.org/learn/)
Chapter 1: Intro (Overview of what GraphQL is ( query language not tied to any specific database or storage ) and how to create a service in which wee need to define types and fields for those types and then provide function for each of those fields. On receiving queries they are first checked to ensure they only refer to types and fields defined.
Questions: I don't really understand how the functions are associated a specific field but I guess i'll be explained further on.
https://graphql.org/learn/queries/)
Chapter 2: Queries and Mutations (https://graphql.org/learn/queries/#fields)
Fields (Essentially GraphQL is about asking for specific fields on objects. fields can be object and we decide what field of the object we want to fetch preventing overfetching and making it easy to get any specific field. GraphQL queries look the same for both single items or lists of items, we know which one to expect based on what is indicated in the schema.
Questions: Is there any easy way to get all fields of a object instead of having to declare every field on the query ?
https://graphql.org/learn/queries/#arguments)
Arguments (Every field and nested object can get its own set of arguments, we can even pass arguments into scalar fields, to implement data transformations once on the server.
https://graphql.org/learn/queries/#aliases)
Aliases (The result object fields match the name of the field, if we want to query the same field multiple times with different parameters on the same request wee need these aliases to avoid object naming conflicts.
https://graphql.org/learn/queries/#fragments)
Fragments (A fragment is basically a reusable piece of query ( In GraphQL, is very common the need to query for the same data fields in different queries ).
https://graphql.org/learn/queries/#operation-name)
Operation Name (The operation type is either query, mutation, or subscription and describes what type of operation you're intending to do, it's mostly required The operation name is a meaningful and explicit name for your operation, not always required but his use is encouraged becase it make easier debugging.
https://graphql.org/learn/queries/#variables)
Variables (In case parameters of our query are dynamic we use variables. In order to this variables to work we need to follow three steps:
- Replace the static value in the query with $variableName
- Declare $variableName as one of the variables accepted by the query
- Pass variableName: value in the separate, transport-specific (usually JSON) variables dictionary
Variables argumentes can be required by setting !
after type when we declare the variables accepted by our query: query HeroNameAndFriends($episode: Episode!)
Variables can also have a default values by adding the default value after the type declaration
https://graphql.org/learn/queries/#directives)
Directives (Directives are used to dynamically change the structure and shape of our queries using variables. The core GraphQL specification includes exactly two directives:
@include(if: Boolean)
@skip(if: Boolean)
https://graphql.org/learn/queries/#mutations)
Mutations (Same as in REST Api where the convention is not to do any modification on GET requests, here in GraphQL there's a convention that any operations that cause writes should be sent explicitly via a mutation operation type. Important detail -> mutation fields run in series, one after the other.
https://graphql.org/learn/queries/#inline-fragments)
Inline Fragments (We can use inline fragments in case a query field return multiple types with different fields between them and we want to retrieve different information depending on which type was returned.
Also there is a meta field called __typename
which allow us to get at any point in a query name of the object type at that point.