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
The `g` export exported from `@graphql-ts/schema` directly is now deprecated. Using `initG` is now the recommended way to use `@graphql-ts/schema` instead of the instance of `g` exported by `@graphql-ts/schema` or creating multiple files to setup `g` though using those is still possible.
6
+
7
+
```ts
8
+
import { GraphQLSchema } from"graphql";
9
+
import { initG } from"@graphql-ts/schema";
10
+
11
+
typeContext= {
12
+
something:string;
13
+
};
14
+
15
+
const g =initG<Context>();
16
+
typeg<T> =initG<T>;
17
+
18
+
const Query =g.object()({
19
+
name: "Query",
20
+
fields: {
21
+
something: g.field({
22
+
type: g.String,
23
+
resolve(_, __, context) {
24
+
returncontext.something;
25
+
},
26
+
}),
27
+
},
28
+
});
29
+
30
+
const schema =newGraphQLSchema({
31
+
query: Query,
32
+
});
33
+
```
34
+
35
+
All types available at `g.*` like `g.ObjectType<Source>` can written instead like `g<typeof g.object<Source>>`/`GObjectType<Source, Context>` instead of being accessible directly on `g`.
0 commit comments