@@ -2,17 +2,58 @@ import { GraphQLString, GraphQLSchema, GraphQLObjectType } from 'graphql/type';
2
2
import { ExecutionResult } from 'graphql/execution' ;
3
3
import { graphqlSync } from 'graphql' ;
4
4
5
+ interface SomeExtension {
6
+ number : number ;
7
+ string : string ;
8
+ }
9
+
10
+ const example : SomeExtension = {
11
+ number : 42 ,
12
+ string : 'Meaning of life' ,
13
+ } ;
14
+
15
+ // The following code block requires a newer version of TypeScript
16
+ /*! >=3.2
17
+
18
+ declare module 'graphql' {
19
+ interface GraphQLObjectTypeExtensions<TSource = any, TContext = any> {
20
+ someObjectExtension?: SomeExtension;
21
+ }
22
+ interface GraphQLFieldExtensions<
23
+ TSource,
24
+ TContext,
25
+ TArgs = { [argName: string]: any }
26
+ > {
27
+ someFieldExtension?: SomeExtension;
28
+ }
29
+ interface GraphQLArgumentExtensions {
30
+ someArgumentExtension?: SomeExtension;
31
+ }
32
+ }
33
+ */
34
+
5
35
const queryType : GraphQLObjectType = new GraphQLObjectType ( {
6
36
name : 'Query' ,
7
37
fields : {
8
38
sayHi : {
9
39
type : GraphQLString ,
10
40
args : {
11
- who : { type : GraphQLString } ,
41
+ who : {
42
+ type : GraphQLString ,
43
+ extensions : {
44
+ someArgumentExtension : example ,
45
+ } ,
46
+ } ,
12
47
} ,
13
48
resolve : ( _root , args ) => 'Hello ' + ( args . who || 'World' ) ,
49
+ extensions : {
50
+ someFieldExtension : example ,
51
+ } ,
14
52
} ,
15
53
} ,
54
+ extensions : {
55
+ someObjectExtension : example ,
56
+ } ,
16
57
} ) ;
17
58
18
59
const schema : GraphQLSchema = new GraphQLSchema ( {
0 commit comments