in packages/graphql-types-generator/src/compiler/index.ts [200:231]
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));
}
}
}