Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/green-seals-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@graphql-ts/extend": patch
"@graphql-ts/schema": patch
---

Add support for `graphql@17`
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
graphql: ["16.0.0", "16.14.2"]
graphql: ["16.0.0", "16.14.2", "17.0.2"]
steps:
- uses: actions/checkout@main

Expand All @@ -29,6 +29,10 @@ jobs:
- name: Check Types
run: pnpm run all:types

- name: Check GraphQL 17 Type Contracts
if: matrix.graphql == '17.0.2'
run: pnpm run graphql17:types

- name: Check GraphQL 16 Type Contracts
if: startsWith(matrix.graphql, '16.')
run: pnpm run graphql16:types
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-graphql-yoga/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"dependencies": {
"@graphql-ts/schema": "^1.0.2",
"graphql": "^16.3.0",
"graphql": "^17.0.2",
"graphql-yoga": "^5.22.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/drizzle-graphql-yoga/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dependencies": {
"@graphql-ts/schema": "^1.0.2",
"drizzle-orm": "^1.0.0-rc.4",
"graphql": "^16.3.0",
"graphql": "^17.0.2",
"graphql-yoga": "^5.22.0"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"types": "tsc",
"all:types": "pnpm run /^types.*/ && pnpm -r run types",
"graphql16:types": "tsc -p test-project/graphql-16/tsconfig.json && ./node_modules/ts-5-7/bin/tsc -p test-project/graphql-16/tsconfig.json",
"graphql17:types": "tsc -p test-project/graphql-17/tsconfig.json && ./node_modules/ts-5-7/bin/tsc -p test-project/graphql-17/tsconfig.json",
"lint": "oxlint . && oxfmt --check .",
"site": "cd site && pnpm dev",
"build": "preconstruct build",
Expand Down
4 changes: 2 additions & 2 deletions packages/extend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"license": "MIT",
"peerDependencies": {
"@graphql-ts/schema": "^1.0.0",
"graphql": "16"
"graphql": "16 || 17"
},
"devDependencies": {
"@graphql-ts/schema": "workspace:^",
"graphql": "^16.3.0"
"graphql": "^17.0.2"
},
"repository": "https://github.com/Thinkmill/graphql-ts/tree/main/packages/extend"
}
4 changes: 2 additions & 2 deletions packages/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
],
"license": "MIT",
"peerDependencies": {
"graphql": "16"
"graphql": "16 || 17"
},
"devDependencies": {
"graphql": "^16.3.0"
"graphql": "^17.0.2"
},
"repository": "https://github.com/Thinkmill/graphql-ts/tree/main/packages/schema"
}
57 changes: 52 additions & 5 deletions packages/schema/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
* @module
*/
import type {
GraphQLArgumentConfig,
GraphQLArgumentExtensions,
GraphQLEnumType,
GraphQLEnumTypeConfig,
GraphQLFieldConfigMap,
GraphQLEnumValueConfig,
GraphQLFieldExtensions,
GraphQLFieldMap,
GraphQLInputField,
GraphQLInputFieldExtensions,
GraphQLInputObjectType,
Expand All @@ -33,6 +36,17 @@ import type { g } from "./g-for-doc-references.ts";

type Maybe<T> = T | null | undefined;

export type GraphQLDefaultInput = GraphQLArgumentConfig["default" &
keyof GraphQLArgumentConfig];

export type NativeDefault<
Value,
IsRequired extends boolean = undefined extends Value ? false : true,
> = "default" extends keyof GraphQLArgumentConfig
? Pick<GraphQLArgumentConfig, "default" & keyof GraphQLArgumentConfig> &
(IsRequired extends true ? { default: Value } : { default?: Value })
: {};

export type GNullableOutputType<Context> =
| GScalarType
| GObjectType<any, Context>
Expand Down Expand Up @@ -240,6 +254,9 @@ export class GUnionType<Source, Context> extends GraphQLUnionType {
>
);
resolveType: Maybe<GraphQLTypeResolver<Source, Context>>;
toConfig(): Omit<ReturnType<GraphQLUnionType["toConfig"]>, "resolveType"> & {
resolveType?: Maybe<GraphQLTypeResolver<Source, Context>>;
};
}

export type GUnionTypeConfig<
Expand Down Expand Up @@ -287,6 +304,7 @@ export class GInterfaceType<
Context,
> extends GraphQLInterfaceType {
declare resolveType: Maybe<GraphQLTypeResolver<Source, Context>>;
getFields(): GraphQLFieldMap<Source, Context>;
constructor(
config: Readonly<
GInterfaceTypeConfig<
Expand All @@ -297,8 +315,24 @@ export class GInterfaceType<
>
>
);
toConfig(): Omit<ReturnType<GraphQLInterfaceType["toConfig"]>, "fields"> & {
fields: Fields;
toConfig(): Omit<
ReturnType<GraphQLInterfaceType["toConfig"]>,
"fields" | "resolveType"
> & {
fields: {
[Key in keyof Fields]: Fields[Key] & {
args: {
[Arg in keyof NonNullable<Fields[Key]["args"]>]: NativeDefault<
GraphQLDefaultInput,
true
> & {
extensions: Readonly<GraphQLArgumentExtensions>;
};
};
extensions: Readonly<GraphQLFieldExtensions<Source, Context>>;
};
};
resolveType?: Maybe<GraphQLTypeResolver<Source, Context>>;
};
}

Expand Down Expand Up @@ -452,7 +486,10 @@ export class GEnumType<
constructor(config: Readonly<GEnumTypeConfig<Values>>);
toConfig(): Omit<ReturnType<GraphQLEnumType["toConfig"]>, "values"> & {
values: {
[Name in keyof Values]: Partial<GEnumValueConfig<Values[Name]>>;
[Name in keyof Values]: ReturnType<
GraphQLEnumType["toConfig"]
>["values"][string] &
Partial<GEnumValueConfig<Values[Name]>>;
};
};
}
Expand All @@ -478,6 +515,16 @@ type Flatten<T> = {
[K in keyof T]: T[K];
} & {};

// this is so that on graphql 16 and below where GraphQLNonNull and GraphQLList are structurally compatible
// we make them non-compatible with a get [Symbol.toStringTag]() with a string literal
// but in graphql 17, properties were added to make them incompatible so we don't need to do this anymore
// this means that on graphql 17 GraphQLNonNull and GNonNull are assignable in both directions
// and same for GraphQLList and GList
type GNonNullToStringTag =
GraphQLNonNull<any> extends GraphQLList<any> ? "GraphQLNonNull" : string;
type GListToStringTag =
GraphQLNonNull<any> extends GraphQLList<any> ? "GraphQLList" : string;

/**
* A GraphQL non-null type. This should generally be constructed with
* {@link g.nonNull}.
Expand Down Expand Up @@ -513,7 +560,7 @@ type Flatten<T> = {
export class GNonNull<
Of extends GNullableType<any>,
> extends GraphQLNonNull<Of> {
get [Symbol.toStringTag](): "GraphQLNonNull";
get [Symbol.toStringTag](): GNonNullToStringTag;
}

/**
Expand Down Expand Up @@ -547,7 +594,7 @@ export class GNonNull<
* `GraphQLNonNull` and `GraphQLList` types.
*/
export class GList<Of extends GType<any>> extends GraphQLList<Of> {
get [Symbol.toStringTag](): "GraphQLList";
get [Symbol.toStringTag](): GListToStringTag;
}

export {};
90 changes: 45 additions & 45 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading