Skip to content

Commit 0796b01

Browse files
valbersxperiandri
authored andcommitted
Trying to improve doc. of execution-pipline.md by correcting and...
rephrasing.
1 parent 3a4fc85 commit 0796b01

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

docs/execution-pipeline.md

+32-32
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
11

2-
Technical overview over execution pipeline
2+
Server execution pipeline
33
======================
44

5-
The major work done by FSharp.Data.GraphQL server can be split into several phases:
5+
The major work done by FSharp.Data.GraphQL.Server consists of the following phases:
66

7-
1. Compilation phase, which is executed once when a new `Schema` is being created.
8-
2. Planning phase, when GraphQL query string has been supplied.
9-
3. Execution phase, when query is being executed and result is produced.
7+
1. Compilation phase: when a new `Schema` is being created;
8+
2. Planning phase: when a GraphQL query as a raw string has been supplied;
9+
3. Execution phase: when a query is being executed and a result is produced
1010

1111
## Compilation phase
1212

13-
Compilation phase is called, when we're creating a new schema instance. From this point, all types defined within that schema should remain unchanged. During this step, server will invoke all operations that can be done ahead of time, before actual queries can be handled. This also means that creating a new schema is expensive process, and **should not** be done on each request.
13+
The compilation phase is when we're creating a new schema instance. After the schema is created, all types defined within that schema will remain unchanged. Also during this phase, the server will invoke all operations that can be done independent of any future query. Creating a new schema is an expensive process which is independent of any request and therefore **should not** be done on each request.
1414

15-
Compilation phase performs several operations:
15+
During the compilation phase, basically the following operations are performed:
1616

17-
- Validates, if all type definitions conform GraphQL specification.
18-
- Creates an [introspection](https://facebook.github.io/graphql/#sec-Introspection)-oriented representation of the schema.
19-
- Prepares value resolution pipeline for each of the fields defined in the schema.
17+
- Validation that all type definitions conform to the GraphQL specification;
18+
- Creation of an [introspection](https://facebook.github.io/graphql/#sec-Introspection)-oriented representation of the schema;
19+
- Preparation of a value resolution pipeline for each of the fields defined in the schema.
2020

2121
## Planning phase
2222

23-
In many cases planning and execution phases are called together. This however can be changed by calling `schema.CreateExecutionPlan(graphQlQueryString)`, which produces so-called `ExecutionPlan` without actually executing a query.
23+
In many cases, it makes sense to handle planning and execution phases sequentially as one big phase. However, one can handle them separately by calling `schema.CreateExecutionPlan(graphQlQueryString)`, which produces a so-called `ExecutionPlan` without actually executing a query.
2424

2525
As the name suggests, `ExecutionPlan` and its components (a tree of objects known as `ExecutionInfo`s) describes how the query is going to be executed. This includes:
2626

27-
- Inlining GraphQL query fragments.
28-
- Defining fields resolution strategy - serial or parallel.
29-
- Combining information from query AST (resolved fields / aliases) with server-side information about them (field and type definitions).
30-
- Preparation of the hooks in the execution chain, that will be supplied with potential variables upon execution.
27+
- Inlining GraphQL query fragments;
28+
- Defining fields resolution strategy - sequential or parallel;
29+
- Combining information from the query AST (resolved fields / aliases) with server-side information about them (field and type definitions);
30+
- Preparation of the hooks in the execution chain that will be supplied with potential variables upon execution.
3131

32-
Spliting planning and execution phases is a good idea, when you have the same GraphQL query requested many times (with potentially different variables). This way you can compute execution plan once and cache it. You can use `executionPlan.DocumentId` as a cache identifier. DocumentId is also returned as one of the top level fields in GraphQL response, so it can be used from the client side. Other GraphQL implementations describe that technique as **persistent queries**.
32+
Spliting planning and execution phases is a good idea when you have the same GraphQL query requested many times (with potentially different variables). This way you can compute the execution plan once and cache it. You can use `executionPlan.DocumentId` as a cache identifier. DocumentId is also returned as one of the top level fields in GraphQL response, so it can be used from the client side. Other GraphQL implementations describe that technique as **persistent queries**.
3333

3434
## Execution phase
3535

36-
Execution phase is performed, when we want to resolve response from GraphQL server given query execution plan and optional set of variables provided by the client. Usually it's called together with planning phase descibed above.
36+
The execution phase is performed when we want to resolve a response from an GraphQL server given a query execution plan and an optional set of variables provided by the client. Usually it's called together with the planning phase descibed above.
3737

38-
During execution phase, we perform a traversal over execution plan tree, create an execution context objects for each of the fields and supply them along with data resolved from previous higher level resolver responses recrusively.
38+
During execution phase, we perform a traversal of the execution plan tree; create execution context objects for each of the fields and supply them along with data resolved from previous higher level resolver responses recursively.
3939

40-
Field resolution context contains all of the necessary metadata about things such as:
40+
A field resolution context contains metadata such as:
4141

42-
- Executing schema itself.
43-
- Variables provided with the request.
44-
- Field parameters (in case if field defined any arguments).
45-
- Type definition of both parent and expected return type.
46-
- ExecutionInfo which is fragment of the execution plan itself related to current field and all of its subsequent fields.
42+
- Information about the execution of the schema itself;
43+
- Variables provided with the request;
44+
- Field parameters (in case the corresponding field defined any arguments);
45+
- Type definition of both parent and expected return type;
46+
- `ExecutionInfo` which is a fragment of the execution plan itself related to the current field and all of its subsequent fields.
4747

48-
Execution phase can be performed using one of the two strategies:
48+
The execution phase can be performed using one of the two strategies:
4949

50-
- **Parallel**, where asynchronous fields can be resolved in unordered manner. This is default option in case of GraphQL queries due to fact, that they are readonly operations.
51-
- **Sequential** where asynchronous fields must be resolved in correct order (as it was defined in query string). This is default mode for GraphQL mutations.
50+
- **Parallel**: in which asynchronous fields can be resolved in any order. This is the default mode for GraphQL queries due to the fact that they are readonly operations.
51+
- **Sequential**: in which asynchronous fields must be resolved in a specific order: as it was defined in the query. This is default mode for GraphQL mutations.
5252

53-
As result of GraphQL query execution, a dictionary with resolved values will be returned. It contains following fields:
53+
The result of a GraphQL query execution is a dictionary with resolved values. This dictionary contains the following fields:
5454

55-
- `documentId` which is query AST document hash code - it can be used to implement execution plan caching.
56-
- `data` with a formated GraphQL response matching the requested query string.
57-
- `errors` entry is optional. If it has been provided, it will contain list of errors, that occured during query execution.
55+
- `documentId`: which is the hash code of the query's AST document - it can be used to implement execution plan caching (persistent queries).
56+
- `data`: with a formated GraphQL response matching the requested query.
57+
- `errors`: optional. If it has been provided, it will contain a list of errors that occured during query execution.
5858

59-
This result can be serialized directly and returned to the client.
59+
This result can then be serialized and returned to the client.

0 commit comments

Comments
 (0)