diff --git a/.changeset/afraid-geckos-bow.md b/.changeset/afraid-geckos-bow.md index 31741d7..5203d37 100644 --- a/.changeset/afraid-geckos-bow.md +++ b/.changeset/afraid-geckos-bow.md @@ -2,7 +2,7 @@ "@graphql-ts/schema": major --- -The following types are now deprecated and have replacements as follows: +The following types have been replaced as follows: - `ObjectType` -> `GObjectType` - `EnumType` -> `GEnumType` diff --git a/.changeset/purple-beers-mate.md b/.changeset/purple-beers-mate.md index e434d5a..e9fafad 100644 --- a/.changeset/purple-beers-mate.md +++ b/.changeset/purple-beers-mate.md @@ -2,7 +2,7 @@ "@graphql-ts/schema": major --- -The `g` export exported from `@graphql-ts/schema` directly is now deprecated. Using `gWithContext` 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. +The `g` and `graphql` exports from `@graphql-ts/schema` have been removed. You should now use `gWithContext` to bind `g` to a specific context type. ```ts import { GraphQLSchema } from "graphql"; diff --git a/packages/schema/api-with-context/package.json b/packages/schema/api-with-context/package.json deleted file mode 100644 index 993370b..0000000 --- a/packages/schema/api-with-context/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "main": "dist/graphql-ts-schema-api-with-context.cjs.js", - "module": "dist/graphql-ts-schema-api-with-context.esm.js" -} diff --git a/packages/schema/api-without-context/package.json b/packages/schema/api-without-context/package.json deleted file mode 100644 index 75dab17..0000000 --- a/packages/schema/api-without-context/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "main": "dist/graphql-ts-schema-api-without-context.cjs.js", - "module": "dist/graphql-ts-schema-api-without-context.esm.js" -} diff --git a/packages/schema/package.json b/packages/schema/package.json index 4e31dc5..e9bad41 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -10,16 +10,6 @@ "module": "./dist/graphql-ts-schema.esm.js", "default": "./dist/graphql-ts-schema.cjs.js" }, - "./api-with-context": { - "types": "./api-with-context/dist/graphql-ts-schema-api-with-context.cjs.js", - "module": "./api-with-context/dist/graphql-ts-schema-api-with-context.esm.js", - "default": "./api-with-context/dist/graphql-ts-schema-api-with-context.cjs.js" - }, - "./api-without-context": { - "types": "./api-without-context/dist/graphql-ts-schema-api-without-context.cjs.js", - "module": "./api-without-context/dist/graphql-ts-schema-api-without-context.esm.js", - "default": "./api-without-context/dist/graphql-ts-schema-api-without-context.cjs.js" - }, "./package.json": "./package.json" }, "files": [ @@ -36,12 +26,5 @@ "devDependencies": { "graphql": "^16.3.0" }, - "repository": "https://github.com/Thinkmill/graphql-ts/tree/main/packages/schema", - "preconstruct": { - "entrypoints": [ - "index.ts", - "api-with-context/index.ts", - "api-without-context/index.ts" - ] - } + "repository": "https://github.com/Thinkmill/graphql-ts/tree/main/packages/schema" } diff --git a/packages/schema/src/api-with-context/api-with-context.d.ts b/packages/schema/src/api-with-context/api-with-context.d.ts deleted file mode 100644 index ea1886a..0000000 --- a/packages/schema/src/api-with-context/api-with-context.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { GWithContext } from "../output"; - -declare const __graphql: GWithContext; - -export = __graphql; diff --git a/packages/schema/src/api-with-context/api-with-context.js b/packages/schema/src/api-with-context/api-with-context.js deleted file mode 100644 index fadaa1c..0000000 --- a/packages/schema/src/api-with-context/api-with-context.js +++ /dev/null @@ -1,7 +0,0 @@ -import { g } from "@graphql-ts/schema"; - -export const { field, fields, interfaceField, object, union } = g; - -const interfaceType = g.interface; - -export { interfaceType as interface }; diff --git a/packages/schema/src/api-with-context/index.ts b/packages/schema/src/api-with-context/index.ts deleted file mode 100644 index 6914a6a..0000000 --- a/packages/schema/src/api-with-context/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @module - * @deprecated This entrypoint should no longer be used. Use {@link gWithContext} - * instead. - */ -import { gWithContext } from "@graphql-ts/schema"; -export { - field, - fields, - interfaceField, - object, - union, - interface, -} from "./api-with-context"; diff --git a/packages/schema/src/api-without-context/api-without-context.d.ts b/packages/schema/src/api-without-context/api-without-context.d.ts deleted file mode 100644 index ea1886a..0000000 --- a/packages/schema/src/api-without-context/api-without-context.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { GWithContext } from "../output"; - -declare const __graphql: GWithContext; - -export = __graphql; diff --git a/packages/schema/src/api-without-context/api-without-context.js b/packages/schema/src/api-without-context/api-without-context.js deleted file mode 100644 index 62611e4..0000000 --- a/packages/schema/src/api-without-context/api-without-context.js +++ /dev/null @@ -1,19 +0,0 @@ -import { g } from "@graphql-ts/schema"; - -export const { - Boolean, - Float, - ID, - Int, - String, - arg, - enumValues, - inputObject, - list, - nonNull, - scalar, -} = g; - -const enumType = g.enum; - -export { enumType as enum }; diff --git a/packages/schema/src/api-without-context/index.ts b/packages/schema/src/api-without-context/index.ts deleted file mode 100644 index ca1bce5..0000000 --- a/packages/schema/src/api-without-context/index.ts +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @module - * @deprecated This entrypoint should no longer be used. Use {@link gWithContext} - * instead. - */ -import { gWithContext } from "@graphql-ts/schema"; -export { - arg, - inputObject, - Boolean, - Float, - ID, - Int, - String, - list, - nonNull, - enum, - enumValues, - scalar, -} from "./api-without-context"; -export type { - InferValueFromOutputType, - InferValueFromArg, - InferValueFromArgs, - InferValueFromInputType, -} from "../types"; - -import type { - GArg, - GEnumType, - GInputObjectType, - GInputType, - GList, - GNonNull, - GNullableInputType, - GNullableType, - GScalarType, - GType, -} from "../types"; - -/** - * @deprecated Use {@link GEnumType} or {@link enumType `g>`} - * instead - */ -export type EnumType = - GEnumType; -/** @deprecated Use {@link GArg} or {@link arg `g>`} instead */ -export type Arg< - Type extends GInputType, - HasDefaultValue extends boolean = boolean, -> = GArg; -/** @deprecated Use {@link GList} or {@link list `g>`} instead */ -export type ListType> = GList; -/** - * @deprecated Use {@link GNonNull} or {@link nonNull `g>`} - * instead - */ -export type NonNullType> = GNonNull; - -/** - * @deprecated Use {@link GScalarType} or {@link scalar `g>`} - * instead - */ -export type ScalarType = GScalarType< - Internal, - External ->; - -/** - * @deprecated Use {@link GInputObjectType} or - * {@link inputObject `g>`} instead - */ -export type InputObjectType< - Fields extends { - [key: string]: IsOneOf extends true - ? GArg - : GArg; - }, - IsOneOf extends boolean = false, -> = GInputObjectType; -/** @deprecated Use {@link GNullableInputType} instead */ -export type NullableInputType = GNullableInputType; -/** @deprecated Use {@link GInputType} instead */ -export type InputType = GInputType; diff --git a/packages/schema/src/index.ts b/packages/schema/src/index.ts index c73507a..bb59731 100644 --- a/packages/schema/src/index.ts +++ b/packages/schema/src/index.ts @@ -123,76 +123,3 @@ export { type InferValueFromArgs, type InferValueFromInputType, } from "./types"; -export { g } from "./schema-api"; - -export type { - Arg, - EnumType, - InputObjectType, - InputType, - NullableInputType, - ListType, - NonNullType, - ScalarType, -} from "./api-without-context"; - -import type { - GArg, - GField, - GFieldResolver, - GInputType, - GInterfaceField, - GInterfaceType, - GNullableOutputType, - GNullableType, - GObjectType, - GOutputType, - GType, - GUnionType, -} from "./types"; - -/** @deprecated Use {@link GField} instead */ -export type Field< - Source, - Args extends { [Key in keyof Args]: GArg }, - Type extends GOutputType, - SourceAtKey, - Context, -> = GField; -/** @deprecated Use {@link GFieldResolver} instead */ -export type FieldResolver< - Source, - Args extends Record>, - Type extends GOutputType, - Context, -> = GFieldResolver; - -/** @deprecated Use {@link GInterfaceField} instead */ -export type InterfaceField< - Args extends Record>, - Type extends GOutputType, - Context, -> = GInterfaceField; -/** @deprecated Use {@link GInterfaceType} instead */ -export type InterfaceType< - Source, - Fields extends Record< - string, - GInterfaceField, Context> - >, - Context, -> = GInterfaceType; -/** @deprecated Use {@link GNullableOutputType} instead */ -export type NullableOutputType = GNullableOutputType; -/** @deprecated Use {@link GObjectType} instead */ -export type ObjectType = GObjectType; -/** @deprecated Use {@link GOutputType} instead */ -export type OutputType = GOutputType; -/** @deprecated Use {@link GUnionType} instead */ -export type UnionType = GUnionType; -/** @deprecated Use {@link GType} instead */ -export type Type = GType; -/** @deprecated Use {@link GNullableType} instead */ -export type NullableType = GNullableType; - -export * from "./schema-api-alias"; diff --git a/packages/schema/src/output.ts b/packages/schema/src/output.ts index 3374fc9..b0eb474 100644 --- a/packages/schema/src/output.ts +++ b/packages/schema/src/output.ts @@ -7,10 +7,6 @@ import type { GraphQLInputFieldConfig, GraphQLScalarTypeConfig, } from "graphql"; -import type { - InferValueFromArgs, - InferValueFromInputType, -} from "./api-without-context"; import { GArg, GEnumType, @@ -33,6 +29,8 @@ import { GType, GUnionType, InferValueFromOutputType, + InferValueFromArgs, + InferValueFromInputType, } from "./types"; import { GraphQLBoolean, diff --git a/packages/schema/src/schema-api-alias.d.ts b/packages/schema/src/schema-api-alias.d.ts deleted file mode 100644 index f69c905..0000000 --- a/packages/schema/src/schema-api-alias.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { g as _graphql } from "./schema-api"; - -/** - * The `graphql` export has been renamed to `g`. - * - * To quickly update usages of `graphql` in your project to `g`: - * - * 1. Navigate to - * `node_modules/@graphql-ts/schema/dist/declarations/src/schema-api-alias.d.ts` - * in your editor ("Go to Definition" will not take you to the correct file) - * 2. Use "Rename Symbol" to rename `graphql` to `g`, this will update usages of - * `graphql` to `g` - * 3. Change this deprecated alias back from `g` to `graphql` using normal text - * editing (avoid using "Rename Symbol" again because you want to preserve - * the updates you made in step 2) - * - * You can also use "Rename Symbol" to quickly rename your own custom defined - * `graphql` export to `g`. - * - * @deprecated - */ -// this is what you should run "Rename Symbol" on -// when that is done, you should change it back to `export import graphql = _graphql;` -// avoid using "Rename Symbol" to revert it because you want to -// preserve the updates you made to the usages of `graphql` -// ||||||| -// vvvvvvv -export import graphql = _graphql; diff --git a/packages/schema/src/schema-api-alias.js b/packages/schema/src/schema-api-alias.js deleted file mode 100644 index 4aa9de3..0000000 --- a/packages/schema/src/schema-api-alias.js +++ /dev/null @@ -1 +0,0 @@ -export { g as graphql } from "./schema-api"; diff --git a/packages/schema/src/schema-api.ts b/packages/schema/src/schema-api.ts deleted file mode 100644 index 9eb5ae8..0000000 --- a/packages/schema/src/schema-api.ts +++ /dev/null @@ -1,155 +0,0 @@ -import type { - GArg, - GEnumType, - GField, - GFieldResolver, - GInputObjectType, - GInputType, - GInterfaceField, - GInterfaceType, - GList, - GNonNull, - GNullableInputType, - GNullableOutputType, - GNullableType, - GObjectType, - GOutputType, - GScalarType, - GType, - GUnionType, - InferValueFromInputType as _InferValueFromInputType, - InferValueFromArgs as _InferValueFromArgs, - InferValueFromOutputType as _InferValueFromOutputType, - InferValueFromArg as _InferValueFromArg, -} from "./types"; - -import { gWithContext } from "./output"; - -/** - * @deprecated Use {@link gWithContext} to bind `g` to a specific context instead - * of this generic `g` - */ -export const g = gWithContext(); -export type g = gWithContext.infer; - -// eslint-disable-next-line @typescript-eslint/no-namespace -export declare namespace g { - export type Context = unknown; - /** - * @deprecated Use {@link GEnumType} or {@link g.enum `g>`} - * instead - */ - export type EnumType = - GEnumType; - /** @deprecated Use {@link GArg} or {@link g.arg `g>`} instead */ - export type Arg< - Type extends GInputType, - HasDefaultValue extends boolean = boolean, - > = GArg; - /** - * @deprecated Use {@link GList} or {@link g.list `g>`} - * instead - */ - export type ListType> = GList; - /** - * @deprecated Use {@link GNonNull} or - * {@link g.nonNull `g>`} instead - */ - export type NonNullType> = GNonNull; - - /** - * @deprecated Use {@link GScalarType} or - * {@link g.scalar `g>`} instead - */ - export type ScalarType = GScalarType< - Internal, - External - >; - - /** - * @deprecated Use {@link GInputObjectType} or - * {@link g.inputObject `g>`} instead - */ - export type InputObjectType< - Fields extends { - [key: string]: IsOneOf extends true - ? GArg - : GArg; - }, - IsOneOf extends boolean = false, - > = GInputObjectType; - /** @deprecated Use {@link GNullableInputType} instead */ - export type NullableInputType = GNullableInputType; - /** @deprecated Use {@link GInputType} instead */ - export type InputType = GInputType; - - /** @deprecated Use {@link GNullableType} instead. */ - export type NullableType = GNullableType; - /** @deprecated Use {@link GType} instead. */ - export type Type = GType; - /** @deprecated Use {@link GNullableOutputType} instead. */ - export type NullableOutputType = GNullableOutputType; - /** @deprecated Use {@link GOutputType} instead. */ - export type OutputType = GOutputType; - /** @deprecated Use {@link GField} instead. */ - export type Field< - Source, - Args extends Record>, - TType extends GOutputType, - SourceAtKey, - > = GField; - /** @deprecated Use {@link GFieldResolver} instead. */ - export type FieldResolver< - Source, - Args extends Record>, - TType extends GOutputType, - > = GFieldResolver; - /** - * @deprecated Use {@link GObjectType} or - * {@link object `g`} instead. - */ - export type ObjectType = GObjectType; - /** - * @deprecated Use {@link GUnionType} or {@link g.union `g`} - * instead. - */ - export type UnionType = GUnionType; - /** @deprecated Use {@link GInterfaceType} instead. */ - export type InterfaceType< - Source, - Fields extends Record< - string, - GInterfaceField>, OutputType, Context> - >, - > = GInterfaceType; - /** - * @deprecated Use {@link GInterfaceField} or - * {@link g.interfaceField `g`} instead. - */ - export type InterfaceField< - Args extends Record>, - TType extends GOutputType, - > = GInterfaceField; - - /** @deprecated Use {@link _InferValueFromArg `InferValueFromArg`} instead. */ - export type InferValueFromArg> = - _InferValueFromArg; - - /** @deprecated Use {@link _InferValueFromArgs `InferValueFromArgs`} instead. */ - export type InferValueFromArgs>> = - _InferValueFromArgs; - - /** - * @deprecated Use {@link _InferValueFromInputType `InferValueFromInputType`} - * instead. - */ - export type InferValueFromInputType = - _InferValueFromInputType; - - /** - * @deprecated Use {@link _InferValueFromOutputType `InferValueFromOutputType`} - * instead. - */ - export type InferValueFromOutputType> = - _InferValueFromOutputType; -}