@@ -3,14 +3,12 @@ id: api
3
3
title : API Reference
4
4
---
5
5
6
-
7
-
8
6
## CONTEXT
7
+
9
8
[ _ source file_ ] ( https://github.com/Urigo/graphql-modules/blob/master/packages/graphql-modules/src/application/tokens.ts )
10
9
11
10
` CONTEXT ` is an InjectionToken representing the provided ` GraphQLModules.GlobalContext `
12
11
13
-
14
12
``` typescript
15
13
import { CONTEXT , Inject , Injectable } from ' graphql-modules' ;
16
14
@@ -21,80 +19,74 @@ export class Data {
21
19
```
22
20
23
21
## MODULE_ID
22
+
24
23
[ _ source file_ ] ( https://github.com/Urigo/graphql-modules/blob/master/packages/graphql-modules/src/module/tokens.ts )
25
24
26
25
` MODULE_ID ` is an InjectionToken representing module's ID
27
26
28
-
29
27
``` typescript
30
28
import { MODULE_ID , Inject , Injectable } from ' graphql-modules' ;
31
29
32
30
@Injectable ()
33
31
export class Data {
34
32
constructor (@Inject (MODULE_ID ) moduleId : string ) {
35
- console .log (` Data used in ${moduleId } module ` )
33
+ console .log (` Data used in ${moduleId } module ` );
36
34
}
37
35
}
38
36
```
39
37
40
38
## Application
39
+
41
40
[ _ source file_ ] ( https://github.com/Urigo/graphql-modules/blob/master/packages/graphql-modules/src/application/types.ts )
42
41
43
42
A return type of ` createApplication ` function.
44
43
45
- - ` typeDefs ` - A list of type definitions defined by modules.
46
- - ` resolvers ` - An object with resolve functions defined by modules.
47
- - ` schema ` - Ready to use GraphQLSchema object combined from modules.
48
- - ` injector ` - The application (Singleton) injector.
49
- - ` createOperationController ` - Take over control of GraphQL Operation
50
- - ` createSubscription ` - Creates a ` subscribe ` function that runs the subscription phase of GraphQL.
51
- Important when using GraphQL Subscriptions.
52
- - ` createExecution ` - Creates a ` execute ` function that runs the execution phase of GraphQL.
53
- Important when using GraphQL Queries and Mutations.
54
- - ` createSchemaForApollo ` - Experimental
55
- - ` createApolloExecutor ` - Experimental
56
-
57
-
44
+ - ` typeDefs ` - A list of type definitions defined by modules.
45
+ - ` resolvers ` - An object with resolve functions defined by modules.
46
+ - ` schema ` - Ready to use GraphQLSchema object combined from modules.
47
+ - ` injector ` - The application (Singleton) injector.
48
+ - ` createOperationController ` - Take over control of GraphQL Operation
49
+ - ` createSubscription ` - Creates a ` subscribe ` function that runs the subscription phase of GraphQL.
50
+ Important when using GraphQL Subscriptions.
51
+ - ` createExecution ` - Creates a ` execute ` function that runs the execution phase of GraphQL.
52
+ Important when using GraphQL Queries and Mutations.
53
+ - ` createSchemaForApollo ` - Experimental
54
+ - ` createApolloExecutor ` - Experimental
58
55
59
56
## ApplicationConfig
57
+
60
58
[ _ source file_ ] ( https://github.com/Urigo/graphql-modules/blob/master/packages/graphql-modules/src/application/types.ts )
61
59
62
60
Application's configuration object. Represents the first argument of ` createApplication ` function.
63
61
64
- - ` modules ` - A list of GraphQL Modules
65
- - ` providers ` - A list of Providers - read the [ "Providers and Tokens"] ( ./di/providers ) chapter.
66
- - ` middlewares ` - A map of middlewares - read the [ "Middlewares"] ( ./advanced/middlewares ) chapter.
67
- - ` schemaBuilder ` - Creates a GraphQLSchema object out of typeDefs and resolvers
68
-
69
-
62
+ - ` modules ` - A list of GraphQL Modules
63
+ - ` providers ` - A list of Providers - read the [ "Providers and Tokens"] ( ./di/providers ) chapter.
64
+ - ` middlewares ` - A map of middlewares - read the [ "Middlewares"] ( ./advanced/middlewares ) chapter.
65
+ - ` schemaBuilder ` - Creates a GraphQLSchema object out of typeDefs and resolvers
70
66
71
67
## createApplication
68
+
72
69
[ _ source file_ ] ( https://github.com/Urigo/graphql-modules/blob/master/packages/graphql-modules/src/application/application.ts )
73
70
74
71
Creates Application out of Modules. Accepts ` ApplicationConfig ` .
75
72
76
-
77
73
``` typescript
78
74
import { createApplication } from ' graphql-modules' ;
79
75
import { usersModule } from ' ./users' ;
80
76
import { postsModule } from ' ./posts' ;
81
77
import { commentsModule } from ' ./comments' ;
82
78
83
79
const app = createApplication ({
84
- modules: [
85
- usersModule ,
86
- postsModule ,
87
- commentsModule
88
- ]
89
- })
80
+ modules: [usersModule , postsModule , commentsModule ],
81
+ });
90
82
```
91
83
92
84
## createModule
85
+
93
86
[ _ source file_ ] ( https://github.com/Urigo/graphql-modules/blob/master/packages/graphql-modules/src/module/module.ts )
94
87
95
88
Creates a Module, an element used by Application. Accepts ` ModuleConfig ` .
96
89
97
-
98
90
``` typescript
99
91
import { createModule , gql } from ' graphql-modules' ;
100
92
@@ -105,19 +97,19 @@ export const usersModule = createModule({
105
97
` ,
106
98
resolvers: {
107
99
// ...
108
- }
100
+ },
109
101
});
110
102
```
111
103
112
104
## ModuleConfig
105
+
113
106
[ _ source file_ ] ( https://github.com/Urigo/graphql-modules/blob/master/packages/graphql-modules/src/module/types.ts )
114
107
115
108
Module's configuration object. Represents the first argument of ` createModule ` function.
116
109
117
- - ` id ` - Unique identifier of a module
118
- - ` dirname ` - Pass ` __dirname ` variable as a value to get better error messages.
119
- - ` typeDefs ` - An object or a list of GraphQL type definitions (SDL).
120
- - ` resolvers ` - An object or a list of GraphQL resolve functions.
121
- - ` middlewares ` - A map of middlewares - read the [ "Middlewares"] ( ./advanced/middlewares ) chapter.
122
- - ` providers ` - A list of Providers - read the [ "Providers and Tokens"] ( ./di/providers ) chapter.
123
-
110
+ - ` id ` - Unique identifier of a module
111
+ - ` dirname ` - Pass ` __dirname ` variable as a value to get better error messages.
112
+ - ` typeDefs ` - An object or a list of GraphQL type definitions (SDL).
113
+ - ` resolvers ` - An object or a list of GraphQL resolve functions.
114
+ - ` middlewares ` - A map of middlewares - read the [ "Middlewares"] ( ./advanced/middlewares ) chapter.
115
+ - ` providers ` - A list of Providers - read the [ "Providers and Tokens"] ( ./di/providers ) chapter.
0 commit comments