graphql#isSpecifiedScalarType TypeScript Examples
The following examples show how to use
graphql#isSpecifiedScalarType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: barePrefix.ts From graphql-mesh with MIT License | 6 votes |
transformSchema(schema: GraphQLSchema) {
return mapSchema(schema, {
[MapperKind.TYPE]: (type: GraphQLNamedType) => {
if (this.includeTypes && !isSpecifiedScalarType(type)) {
const currentName = type.name;
if (!this.ignoreList.includes(currentName)) {
return renameType(type, this.prefix + currentName);
}
}
return undefined;
},
[MapperKind.ROOT_OBJECT]() {
return undefined;
},
...(this.includeRootOperations && {
[MapperKind.COMPOSITE_FIELD]: (
fieldConfig: GraphQLFieldConfig<any, any>,
fieldName: string,
typeName: string
) => {
return !rootOperations.has(typeName) || // check we're in a root Type
this.ignoreList.includes(typeName) || // check if type is to be ignored
this.ignoreList.includes(`${typeName}.${fieldName}`) // check if field in type is to be ignored
? undefined // do not perform any change
: [`${this.prefix}${fieldName}`, fieldConfig]; // apply prefix
},
}),
});
}
Example #2
Source File: index.ts From amplify-codegen with Apache License 2.0 | 6 votes |
addTypeUsed(type: GraphQLType) {
if (this.typesUsedSet.has(type)) return;
if (
isEnumType(type) ||
isUnionType(type) ||
isInputObjectType(type) ||
isInterfaceType(type) ||
isObjectType(type) ||
(isScalarType(type) && !isSpecifiedScalarType(type))
) {
this.typesUsedSet.add(type);
}
if (isInterfaceType(type) || isUnionType(type)) {
for (const concreteType of this.schema.getPossibleTypes(type)) {
this.addTypeUsed(getNamedType(concreteType));
}
}
if (isInputObjectType(type)) {
for (const field of Object.values(type.getFields())) {
this.addTypeUsed(getNamedType(field.type));
}
}
if (isObjectType(type)) {
for (const fieldType of type.getInterfaces()) {
this.addTypeUsed(getNamedType(fieldType));
}
for (const field of Object.values(type.getFields())) {
this.addTypeUsed(getNamedType(field.type));
}
}
}