
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>;
}
