You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository contains the source code for the GraphQL ASP.NET documentation website. Clone the `develop` branch to view the code and update the documentation. The `master` branch contains the compiled static site served by github pages.
7
+
This repository contains the source code for the GraphQL ASP.NET documentation website.
8
+
9
+
## How to Run The Docs Locally
10
+
0. Clone the `develop` branch
11
+
1. Open a terminal at the repo directory
12
+
2. Execute `yarn install`
13
+
3. Execute `yarn start`
14
+
4. Website starts on `http://localhost:3000` by default
8
15
9
16
10
17
_Documentation created using [Docusaurus v2](https://docusaurus.io)_
The query handler will attempt to register a schema to `/graphql`for its URL, you'll want to ensure that each schema has its own endpoint by updating the individual routes.
36
+
The query handler will attempt to register a schema to `/graphql`as its URL by default; you'll want to ensure that each schema has its own endpoint by updating the individual routes.
You'll most likely want to disable registering of local graph entities (the entities in the startup assembly) on one or both schemas lest you want each schema contain those controllers and graph types.
55
+
You may want to disable the registering of local graph entities (the entities in the startup assembly) on one or both schemas lest you want each schema to contain the same controllers and graph types.
Instead of adding to the end of the existing pipeline you can also call `.Clear()` to remove the default components and rebuild the pipeline from scratch. See below for the list of default middleware components and their order of execution. This can be handy when needing to inject a new component into the middle of the execution chain.
79
79
80
-
> Modifying the pipeline component order can cause unwanted side effects, including breaking the library such that it no longer functions. Take care when adding or removing middleware components.
80
+
:::caution Component order Matters
81
+
Modifying the component order of a pipeline can cause unwanted side effects, including breaking the library such that it no longer functions. Take care when adding or removing middleware components.
82
+
:::
81
83
82
84
## The Context Object
83
85
@@ -89,16 +91,18 @@ Each context object has specific data fields required for it to perform its work
89
91
-`IsValid`: Determines if the context is in a valid and runnable state. Most middleware components will not attempt to process the context if its not in a valid state and will simply forward the request on. By default, a context is automatically invalidated if an error message is added with the `Critical` severity.
90
92
-`SecurityContext`: The information received from ASP.NET containing the credentials of the active user. May be null if user authentication is not setup for your application.
91
93
-`Metrics`: The metrics package performing any profiling of the query. Various middleware components will stop/start phases of execution using this object. If metrics are not enabled this object will be null.
92
-
-`Items`: A key/value pair collection of items. This field is developer driven and not used by the runtime.
94
+
-`Items`: A key/value collection of items available to every context on every pipeline related to a single request. This field is developer driven and not used by the runtime.
93
95
-`Logger`: An `IGraphEventLogger` instance scoped to the the current query.
94
96
95
97
## Middleware is served from the DI Container
96
98
97
-
Each pipeline is registered as a singleton instance in your service provider but the components within the pipeline are invoked according to the service lifetime you supply when you register them allowing you to setup dependencies as necessary.
99
+
Each pipeline is registered as a singleton instance in your service provider but the components within the pipeline are invoked according to the service lifetime you supply when you register them, allowing you to manage dependencies as you see fit.
98
100
99
-
> Register your middleware components with the `Singleton` lifetime scope whenever possible.
101
+
:::tip Register Middleware as Singletons
102
+
Register your middleware components with the `Singleton` lifetime scope whenever possible to boost performance.
103
+
:::
100
104
101
-
It is recommended that your middleware components be singleton in nature if possible. The field execution and item authorization pipelines can be invoked many dozens of times per request and fetching new middleware instances for each invocation can impact performance. The internal pipeline manager will retain references to any singleton middleware components once they are generated and avoid this bottleneck whenever possible. Most default components are registered as a singletons.
105
+
It is recommended that your middleware components be singleton in nature if possible. The field execution and item authorization pipelines can be invoked many dozens of times per request and fetching new middleware instances for each invocation can impact performance. Most default components are registered as a singletons.
102
106
103
107
## Query Execution Pipeline
104
108
@@ -215,5 +219,11 @@ public class GraphDirectiveExecutionContext
215
219
-`Directive`: The specific `IDirective`, registered to the schema, that is being processed.
216
220
-`Schema`: the schema instance where the directive is declared.
217
221
218
-
> WARNING: Since the directive execution pipeline is used to construct the schema and apply type system directives, middleware components cannot inject a schema instance
219
-
> from the DI container. To do so will cause a circular reference. Instead use the schema instance attached to the `GraphDirectiveExecutionContext`. The state of this schema object is not guaranteed at during schema generation as it will continue to change as type system directives are applied by the pipeline.
222
+
### A Note on Schema Instances
223
+
Since the directive execution pipeline is used to construct a schema and apply type system directives, middleware components within it cannot inject a schema instance from the DI container. To do so would cause a circular reference in the DI container.
224
+
225
+
Instead use the schema instance attached to the `GraphDirectiveExecutionContext`.
226
+
227
+
:::note
228
+
You can inject a schema instance into components of every pipeline EXCEPT the Directive Execution Pipeline.
0 commit comments