deno.land / x / pothos@release-1713397530 / packages / plugin-sub-graph / util.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// @ts-nocheckimport { GraphQLList, GraphQLNamedType, GraphQLNonNull, GraphQLType } from 'https://cdn.skypack.dev/graphql?dts';import { PothosSchemaError } from '../core/index.ts';export function replaceType<T extends GraphQLType>(type: T, newTypes: Map<string, GraphQLNamedType>, referencedBy: string, subGraphs: string[]): T { if (type instanceof GraphQLNonNull) { return new GraphQLNonNull(replaceType(type.ofType as GraphQLType, newTypes, referencedBy, subGraphs)) as T; } if (type instanceof GraphQLList) { return new GraphQLList(replaceType(type.ofType, newTypes, referencedBy, subGraphs)) as T; } const newType = newTypes.get((type as GraphQLNamedType).name); if (!newType) { throw new PothosSchemaError(`${(type as GraphQLNamedType).name} (referenced by ${referencedBy}) does not exist in subGraph (${subGraphs})`); } return newType as T;}
pothos

Version Info

Tagged at
a year ago