@cran/lib.gql.core
Version:
GQL Core Functionality
20 lines (17 loc) • 589 B
text/typescript
import type { GraphQLField, GraphQLObjectType } from "graphql";
export function patchField<Source = unknown, Context = unknown> (
object: GraphQLObjectType, name: string,
fieldDefinition: Partial<GraphQLField<Source, Context>>
) {
(object as unknown as {
_fields: Record<string, GraphQLField<Source, Context>>;
})._fields[name] = {
name,
args : [ ],
isDeprecated : false,
deprecationReason: undefined,
description : undefined,
extensions : undefined,
...fieldDefinition,
} as const as GraphQLField<Source, Context>;
}