MCPcopy
hub / github.com/ardatan/graphql-tools / getTypeSpecifiers

Function getTypeSpecifiers

packages/utils/src/mapSchema.ts:441–467  ·  view source on GitHub ↗
(schema: GraphQLSchema, typeName: string)

Source from the content-addressed store, hash-verified

439}
440
441function getTypeSpecifiers(schema: GraphQLSchema, typeName: string): Array<MapperKind> {
442 const type = schema.getType(typeName);
443 const specifiers = [MapperKind.TYPE];
444
445 if (isObjectType(type)) {
446 specifiers.push(MapperKind.COMPOSITE_TYPE, MapperKind.OBJECT_TYPE);
447 if (typeName === schema.getQueryType()?.name) {
448 specifiers.push(MapperKind.ROOT_OBJECT, MapperKind.QUERY);
449 } else if (typeName === schema.getMutationType()?.name) {
450 specifiers.push(MapperKind.ROOT_OBJECT, MapperKind.MUTATION);
451 } else if (typeName === schema.getSubscriptionType()?.name) {
452 specifiers.push(MapperKind.ROOT_OBJECT, MapperKind.SUBSCRIPTION);
453 }
454 } else if (isInputObjectType(type)) {
455 specifiers.push(MapperKind.INPUT_OBJECT_TYPE);
456 } else if (isInterfaceType(type)) {
457 specifiers.push(MapperKind.COMPOSITE_TYPE, MapperKind.ABSTRACT_TYPE, MapperKind.INTERFACE_TYPE);
458 } else if (isUnionType(type)) {
459 specifiers.push(MapperKind.COMPOSITE_TYPE, MapperKind.ABSTRACT_TYPE, MapperKind.UNION_TYPE);
460 } else if (isEnumType(type)) {
461 specifiers.push(MapperKind.ENUM_TYPE);
462 } else if (isScalarType(type)) {
463 specifiers.push(MapperKind.SCALAR_TYPE);
464 }
465
466 return specifiers;
467}
468
469function getTypeMapper(
470 schema: GraphQLSchema,

Callers 1

getTypeMapperFunction · 0.85

Calls 1

getTypeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…