Title: Theory / Important / CS / Programming / Query / GraphQL
Tags: automatedNewLineAfterCommaSpace comment

Name: GraphQL
Definition: a query language for APIs and a runtime for fulfilling those queries with your existing data
Page: https://graphql.org/
Definition2: provides a complete and understandable description of the data in your API
Definition3: gives clients the power to ask for exactly what they need and nothing more
Definition4: makes it easier to evolve APIs over time, and
Definition5: enables powerful developer tools.

Question: Step of a query resolution
Answer: check that the query is well typed
Page: https://graphql.org/learn/
Context: GraphQL
Answer2: search the data to return

Instruction: alias: query
Page: https://graphql.org/learn/queries/
Meaning: result of query
Language: GraphQL
Identifier: alias

Instruction: list_scalar_field_name
Page: https://graphql.org/learn/queries/
Effect: query the list of scalar values of list_scalar_field_name
Language: GraphQL

Instruction: list_object_field_name {foo}
Page: https://graphql.org/learn/queries/
Effect: List of the result of the query
 object_field_name {foo}
on each element of list_object_field_name
Language: GraphQL

Instruction: object_field_name {foo}
Page: https://graphql.org/learn/queries/
Effect: query associate "object_field_name" to the query {foo} on the value associated to object_field_name
Language: GraphQL

Instruction: scalar_field_name
Page: https://graphql.org/learn/queries/
Effect: query associate "scalar_field_name" to the value associated to scalar_field_name
Language: GraphQL

Language: GraphQL
Instruction: #foo
Other fields (not shown on cards):
Page: https://graphql.org/learn/queries/

Instruction: field_name(arg: value)
Page: https://graphql.org/learn/queries/
Effect: indicate that the query resolver should take arg = value into account
Language: GraphQL

Instruction: fragment name on type {
  foo
}
Page: https://graphql.org/learn/queries/
Meaning: in query of object type, this represents the query foo
Language: GraphQL
Identifier: name
Name: A fragment
Assuming: fragment do not refere to itself, even indirectly

Instruction: query name(
  $var_1: type_1 [= default_value_1],
  ...,
  $var_n: type_n [= default_value_n]
) {foo}
Page: https://graphql.org/learn/queries/
Meaning: a query taking potentially arguments arg_1 ... arg_n of type type_i
Language: GraphQL
Identifier: name

Page: https://graphql.org/learn/queries/
Syntactic sugar: {foo}
Implementation: query no_name {foo}
Language: GraphQL

Question: Why should production code always give name to query
Answer: debugging
Page: https://graphql.org/learn/queries/
Context: GraphQL
Answer2: logging

Typ: foo!
Meaning: a non-null value of type foo
Page: https://graphql.org/learn/queries/
Language: GraphQL

Instruction: field_name @include(if: include_it)
Page: https://graphql.org/learn/queries/
Effect: use this field_name iff include_it is true
Language: GraphQL

Instruction: field_name @skip(if: skip_it)
Page: https://graphql.org/learn/queries/
Effect: use this field_name iff skip_it is false
Language: GraphQL

Name: Directive
Definition: An instruction attached to a field or fragment inclusion, and can affect execution of the query in any way the server desires.
Page: https://graphql.org/learn/queries/
Context: GraphQL
Denoted by: @name

Name: input object type
Definition: a special kind of object type that can be passed in as an argument.
Page: https://graphql.org/learn/queries/
Context: GraphQL

Question: Difference in query execution and mutation execution
Answer: query execution is parallel while mutation is serial
Page: https://graphql.org/learn/queries/
Context: GraphQL

Instruction: ... on Type {
  foo
}
Page: https://graphql.org/learn/queries/
Effect: if current object type is Type, then same query as foo. Otherwise nothing
Language: GraphQL
Name: inline fragment
Intuition: Allow to have distinct query depending on the concrete type, when we now only an abstract type

Instruction: __typename
Page: https://graphql.org/learn/queries/
Effect: field whose value is the name of the object type at this point
Language: GraphQL

Typ: [foo]
Meaning: List of values of type foo
Page: https://graphql.org/learn/schema/
Language: GraphQL

Typ: String
Meaning: A UTF-8 character sequence
Page: https://graphql.org/learn/schema/
Language: GraphQL

Instruction: type type_name {
  field_1(args_1): type_1
  ...
  field_n(args_n) : type_n
}
Page: https://graphql.org/learn/schema/
Meaning: a structure with fields field_i taking arguments args_i and returning type type_i
Language: GraphQL
Identifier: type_name

Typ: Float
Meaning: A signed double-precision floating-point value
Page: https://graphql.org/learn/schema/
Language: GraphQL

Page: https://graphql.org/learn/schema/
Syntactic sugar: field: type
Implementation: field(): type
Language: GraphQL type

Instruction: schema {
  query: QueryEntryPoint
  mutation: MutationEntryPoint
}
Page: https://graphql.org/learn/schema/
Effect: state that the entry point of a query/mutation is the type QueryEntryPoint/MutationEntryPoint
Language: GraphQL type

Typ: Int
Meaning: A signed 32-bit integer
Page: https://graphql.org/learn/schema/
Language: GraphQL type

Typ: Boolean
Meaning: true or false
Page: https://graphql.org/learn/schema/
Language: GraphQL type

Typ: ID
Meaning: a unique identifier, often used to refetch an object or as the key for a cache
Page: https://graphql.org/learn/schema/
Language: GraphQL type
Implementation: Not human readable. Concretely a string

Instruction: scalar foo
Page: https://graphql.org/learn/schema/
Meaning: a scalar value that the implementation is in charge to serialize, deserialize and validate
Language: GraphQL type
Identifier: foo

Instruction: enum name {
  value_1
  ...
  value_n
}
Page: https://graphql.org/learn/schema/
Meaning: Exactly one of value_1, ..., value_n
Language: GraphQL type
Identifier: name

Instruction: interface name {
  field_1: type_1
  ...
  field_n: type_n
}
Page: https://graphql.org/learn/schema/
Meaning: A type that can't be implemented, and have at least the fields field_i with type type_i
Language: GraphQL type
Identifier: name

Instruction: type foo implements bar
Page: https://graphql.org/learn/schema/
Effect: same as type foo but fail if foo do not have all of the fields of bar
Language: GraphQL type

Instruction: union name = type_1 | ... | type_n
Page: https://graphql.org/learn/schema/
Meaning: a type which is exactly one of the type_i
Language: GraphQL type
Identifier: name
Assuming: type_i are concrete types, not union or interface

Instruction: input type_name {
  field_1: type_1
  ...
  field_n : type_n
}
Page: https://graphql.org/learn/schema/
Meaning: an input type, with fields field_i of type type_i
Language: GraphQL type
Identifier: type_name

Name: Validation
Definition: Checking whether a query satisfies the query constraints
Page: https://graphql.org/learn/validation/
Context: GraphQL

Instruction: ... on fragment_name
Page: https://graphql.org/learn/validation/
Effect: if the current type is the one of fragment_name, then use this fragment. Otherwise, nothing
Language: GraphQL

Name: The resolver of f
Definition: The function which, given an object O of type T, return O.f
Page: https://graphql.org/learn/execution/
Variables: T a type
f a field of T
Context: GraphQL

Name: The root type
Definition: a type that represents all of the possible entry points into the GraphQL API
Page: https://graphql.org/learn/execution/
Context: GraphQL
Name2: The query type

Instruction: __schema
Page: https://graphql.org/learn/introspection/
Language: GraphQL
Returns: object representing the schema
Where to use it: root of query

Instruction: types
Page: https://graphql.org/learn/introspection/
Language: GraphQL
Returns: list of types defined in our schema and scalars
Where to use it: root.__schema

Instruction: queryType
Page: https://graphql.org/learn/introspection/
Language: GraphQL
Returns: root's query type
Where to use it: root.__schema

Instruction: __type(name: foo)
Page: https://graphql.org/learn/introspection/
Language: GraphQL
Returns: the type named foo

Instruction: name
Page: https://graphql.org/learn/introspection/
Language: GraphQL
Context: __type(name:foo)
Returns: the name of the type

Instruction: kind
Page: https://graphql.org/learn/introspection/
Language: GraphQL
Context: __type(name:foo)
Returns: the kind of the type (object, interface, ...)

Instruction: fields
Page: https://graphql.org/learn/introspection/
Language: GraphQL
Context: __type(name:foo)
Returns: the list of fields

Instruction: ofType
Page: https://graphql.org/learn/introspection/
Language: GraphQL
Context: __type(name:foo)
Returns: the underlying type
Assuming: for list/not_null,

Instruction: description
Page: https://graphql.org/learn/introspection/
Language: GraphQL
Context: __type(name:foo)
Returns: the type's description

Question: What is the preferred protocol for graphQL?
Answer: http with a single endpoint
Page: https://graphql.org/learn/best-practices/

Question: What is the preferred encoding for graphQL?
Answer: gzipped JSON
Page: https://graphql.org/learn/best-practices/

Question: Why GraphQL do not recommand versionning
Answer: request's answer contains only what asked for. Having more elements available do not break anytihng.
Page: https://graphql.org/learn/best-practices/

Question: batching and caching
Answer: todo
Page: https://graphql.org/learn/best-practices/

Question: pagination
Answer: todo
Page: https://graphql.org/learn/best-practices/

Instruction: "errors"
Page: https://graphql.org/learn/serving-over-http/
Language: GraphQL
Context: answer
Returns: The errors iff there was one. Absent otherwise

Instruction: "data"
Page: https://graphql.org/learn/serving-over-http/
Language: GraphQL
Context: answer
Returns: The data. Absent if execution did not start.

Question: What part of the code should deal with authorization
Answer: The business logic layer
Page: https://graphql.org/learn/authorization/
Context: answer

Question: How to deal with a field F which may be a very long list
Answer: You should be able to access the number of elements
Page: https://graphql.org/learn/pagination/
Context: answer
Answer2: F should take an argument indicating the number of elements to return
Answer3: F should also return whether all elements where returned, and an opaque cursor to give back in next query to get the remaining of the list

Typ: node
Meaning: an interface with a single field: Id
Page: https://graphql.org/learn/global-object-identification/
Context: answer
Intuition: Allow to fetch any element by id

Name: GraphiQL
Definition: the reference implementation of GraphQL
Page: https://github.com/graphql/graphiql

Name: GraphQL IDE
Definition: An official IDE to write and validate GraphQL queries given some schema
Page: https://github.com/graphql/graphiql