Extending an existing schema
graphql-ts provides a small library to extend an existing GraphQL schema with new query/mutation fields and types.
Installation
npm install @graphql-ts/extendpnpm add @graphql-ts/extendyarn add @graphql-ts/extendUsage
import { function extend(extension: Extension | readonly Extension[] | ((base: BaseSchemaMeta) => Extension | readonly Extension[])): (schema: GraphQLSchema) => GraphQLSchema
const schema: GraphQLSchema
import g
const newSchema: (schema: GraphQLSchema) => GraphQLSchema
function extend(extension: Extension | readonly Extension[] | ((base: BaseSchemaMeta) => Extension | readonly Extension[])): (schema: GraphQLSchema) => GraphQLSchema
base: BaseSchemaMeta
const existingType: any
base: BaseSchemaMeta
any
query: {    hello: any;    field: any;}
hello: any
const g: any
const field: any
type: any
const g: any
any
resolve: () => string
any
const g: any
any
type: any
const g: any
any
base: BaseSchemaMeta
function object(name: string): GObjectType<unknown, unknown>
function resolve(): never[]
const schema: GraphQLSchema
Limitations
extend only supports extending the query and mutation types. extend also doesn’t support schemas that use the query or mutation types in any types besides as the root query/mutation types.
Also, since there is no TypeScript type information in the existing schema, all existing types that can be used are typed generically e.g. for object types, the source type is unknown and etc.