Skip to content

Commit b502533

Browse files
committed
Return standard GraphQL.js types
1 parent a0d9ea2 commit b502533

29 files changed

+1454
-1366
lines changed

.changeset/brown-buses-look.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@graphql-ts/extend": major
3+
"@graphql-ts/schema": major
4+
---
5+
6+
`graphql@15` is no longer supported. `[email protected]` or newer is now required.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@graphql-ts/extend": major
3+
---
4+
5+
The `wrap` export has been removed. Since the types in `@graphql-ts/[email protected]` are compatible with the GraphQL.js types directly, these functions are no longer needed.

.changeset/new-laws-cough.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
"@graphql-ts/schema": major
3+
---
4+
5+
All of the GraphQL types returned by `@graphql-ts/schema` are now directly runtime compatible with the equivalent types from GraphQL.js instead of being on `.graphQLType`.
6+
7+
Handling this change should generally just require removing `.graphQLType` from where `@graphql-ts/schema` types are used with GraphQL.js, like this:
8+
9+
```diff
10+
import { GraphQLSchema } from "graphql";
11+
import { g } from "@graphql-ts/schema";
12+
13+
const Query = g.object()({
14+
name: "Query",
15+
fields: {
16+
hello: g.field({
17+
type: g.String,
18+
resolve() {
19+
return "Hello!";
20+
},
21+
}),
22+
},
23+
});
24+
25+
const schema = new GraphQLSchema({
26+
- query: Query.graphQLType,
27+
+ query: Query,
28+
});
29+
```
30+
31+
The types returned by `@graphql-ts/schema` are internally now extended classes of the equivalent types from GraphQL.js (though only in the types, at runtime they are re-exports). These new classes are exported from `@graphql-ts/schema/types` as `GObjectType` and etc. The constructors of the `G*` types can be used directly safely in place of `g.*` in **some cases** though some are not safe and it's still recommended to use `g.*` to also have binding to the same context type without needed to provide it manually.

.changeset/silly-eyes-rhyme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@graphql-ts/schema": major
3+
---
4+
5+
The `ObjectTypeFunc` and other `*TypeFunc` types are no longer exported. Use `GraphQLSchemaAPIWithContext<Context>['object']`/etc. instead

.changeset/sour-papayas-cough.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@graphql-ts/schema": major
3+
---
4+
5+
The `EnumValue` type no longer exists. The type parameter for `EnumType` is now `Record<Key, Value>` instead of `Record<Key, EnumValue<Value>>`.

.changeset/tough-apples-sniff.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@graphql-ts/schema": major
3+
---
4+
5+
TypeScript 5.7 or newer is now required

package.json

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@
2222
"jest": "27.0.6",
2323
"prettier": "3.5.2",
2424
"prettier-plugin-jsdoc": "1.3.2",
25-
"ts-5-0": "npm:typescript@^5.0.3",
26-
"ts-5-1": "npm:typescript@^5.1.3",
27-
"ts-5-2": "npm:typescript@^5.2.3",
28-
"ts-5-3": "npm:typescript@^5.3.3",
29-
"ts-5-4": "npm:typescript@^5.4.3",
30-
"ts-5-5": "npm:typescript@^5.5.3",
31-
"ts-5-6": "npm:typescript@^5.6.3",
3225
"typescript": "^5.7.3"
3326
},
3427
"scripts": {
@@ -39,14 +32,7 @@
3932
"all:types": "pnpm run /^types.*/",
4033
"lint": "eslint . && prettier --check .",
4134
"site": "cd site && pnpm dev",
42-
"build": "preconstruct build",
43-
"types:5-0": "./node_modules/ts-5-0/bin/tsc",
44-
"types:5-1": "./node_modules/ts-5-1/bin/tsc",
45-
"types:5-2": "./node_modules/ts-5-2/bin/tsc",
46-
"types:5-3": "./node_modules/ts-5-3/bin/tsc",
47-
"types:5-4": "./node_modules/ts-5-4/bin/tsc",
48-
"types:5-5": "./node_modules/ts-5-5/bin/tsc",
49-
"types:5-6": "./node_modules/ts-5-6/bin/tsc"
35+
"build": "preconstruct build"
5036
},
5137
"preconstruct": {
5238
"packages": [

packages/extend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"license": "MIT",
2020
"peerDependencies": {
2121
"@graphql-ts/schema": "^0.6.0",
22-
"graphql": "15 || 16"
22+
"graphql": "16"
2323
},
2424
"devDependencies": {
2525
"@graphql-ts/schema": "workspace:^",

packages/extend/src/extend.test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const onlyQuery = new GraphQLSchema({
3232
},
3333
}),
3434
},
35-
}).graphQLType,
35+
}),
3636
});
3737

3838
test("basic query", () => {
@@ -114,7 +114,7 @@ test("basic mutation with existing mutations", () => {
114114
},
115115
}),
116116
},
117-
}).graphQLType,
117+
}),
118118
mutation: g.object()({
119119
name: "Mutation",
120120
fields: {
@@ -125,7 +125,7 @@ test("basic mutation with existing mutations", () => {
125125
},
126126
}),
127127
},
128-
}).graphQLType,
128+
}),
129129
});
130130
const extended = extend({
131131
mutation: {
@@ -180,7 +180,7 @@ test("errors when query type is used elsewhere in schema", () => {
180180
}),
181181
});
182182
const initial = new GraphQLSchema({
183-
query: Query.graphQLType,
183+
query: Query,
184184
});
185185
expect(() => {
186186
extend({
@@ -229,8 +229,8 @@ test("errors when query and mutation type is used elsewhere in schema", () => {
229229
}),
230230
});
231231
const initial = new GraphQLSchema({
232-
query: Query.graphQLType,
233-
mutation: Mutation.graphQLType,
232+
query: Query,
233+
mutation: Mutation,
234234
});
235235
expect(() => {
236236
extend({
@@ -291,8 +291,8 @@ test("errors when query and mutation type is used elsewhere in schema", () => {
291291
}),
292292
});
293293
const initial = new GraphQLSchema({
294-
query: Query.graphQLType,
295-
mutation: Mutation.graphQLType,
294+
query: Query,
295+
mutation: Mutation,
296296
});
297297
expect(() => {
298298
extend({
@@ -370,7 +370,7 @@ test("using an existing object type", () => {
370370
},
371371
}),
372372
},
373-
}).graphQLType,
373+
}),
374374
});
375375
const extended = extend((base) => ({
376376
query: {
@@ -455,7 +455,7 @@ test("errors when the type isn't an object type", () => {
455455
},
456456
}),
457457
},
458-
}).graphQLType,
458+
}),
459459
});
460460
expect(() => {
461461
extend((base) => ({
@@ -485,7 +485,7 @@ test(".scalar throws for built-in scalars", () => {
485485
},
486486
}),
487487
},
488-
}).graphQLType,
488+
}),
489489
});
490490
expect(() => {
491491
extend((base) => ({
@@ -520,7 +520,7 @@ test(".scalar works for custom scalars", () => {
520520
},
521521
}),
522522
},
523-
}).graphQLType,
523+
}),
524524
});
525525
const extended = extend((base) => ({
526526
query: {
@@ -554,7 +554,7 @@ test("a good error when there is already a field with the same name in the origi
554554
},
555555
}),
556556
},
557-
}).graphQLType,
557+
}),
558558
});
559559
expect(() => {
560560
extend({
@@ -588,7 +588,7 @@ test("a good error when multiple extensions add a field with the same name", ()
588588
},
589589
}),
590590
},
591-
}).graphQLType,
591+
}),
592592
});
593593
expect(() => {
594594
extend([
@@ -627,7 +627,7 @@ test("multiple extensions work", () => {
627627
},
628628
}),
629629
},
630-
}).graphQLType,
630+
}),
631631
});
632632
const extended = extend([
633633
{

0 commit comments

Comments
 (0)