node_modules/@graphql-tools/utils/index.cjs.js
// addTypes uses toConfig to create a new schema with a new or replaced
addTypes uses toConfig to create a new schema with a new or replaced
addTypes uses toConfig to create a new schema with a new or replaced
function addTypes(schema, newTypesOrDirectives) {
    const queryType = schema.getQueryType();
    const mutationType = schema.getMutationType();
    const subscriptionType = schema.getSubscriptionType();
    const queryTypeName = queryType != null ? queryType.name : undefined;
    const mutationTypeName = mutationType != null ? mutationType.name : undefined;
    const subscriptionTypeName = subscriptionType != null ? subscriptionType.name : undefined;
    const config = schema.toConfig();
    const originalTypeMap = {};
    config.types.forEach(type => {
        originalTypeMap[type.name] = type;
    });
    const originalDirectiveMap = {};
    config.directives.forEach(directive => {
        originalDirectiveMap[directive.name] = directive;
    });
    newTypesOrDirectives.forEach(newTypeOrDirective => {
        if (graphql.isNamedType(newTypeOrDirective)) {
            originalTypeMap[newTypeOrDirective.name] = newTypeOrDirective;
        }
        else if (graphql.isDirective(newTypeOrDirective)) {
            originalDirectiveMap[newTypeOrDirective.name] = newTypeOrDirective;
        }
    });
    const { typeMap, directives } = rewireTypes(originalTypeMap, Object.keys(originalDirectiveMap).map(directiveName => originalDirectiveMap[directiveName]));
    return new graphql.GraphQLSchema({
        ...config,
        query: queryTypeName ? typeMap[queryTypeName] : undefined,
        mutation: mutationTypeName ? typeMap[mutationTypeName] : undefined,
        subscription: subscriptionTypeName != null ? typeMap[subscriptionTypeName] : undefined,
        types: Object.keys(typeMap).map(typeName => typeMap[typeName]),
        directives,
    });
}
function addTypes ( schema , newTypesOrDirectives ) { const queryType = schema . getQueryType ( ) ; const mutationType = schema . getMutationType ( ) ; const subscriptionType = schema . getSubscriptionType ( ) ; const queryTypeName = queryType != null ? queryType . name : undefined ; const mutationTypeName = mutationType != null ? mutationType . name : undefined ; const subscriptionTypeName = subscriptionType != null ? subscriptionType . name : undefined ; const config = schema . toConfig ( ) ; const originalTypeMap = { } ; config . types . forEach ( type => { originalTypeMap [ type . name ] = type ; } ) ; const originalDirectiveMap = { } ; config . directives . forEach ( directive => { originalDirectiveMap [ directive . name ] = directive ; } ) ; newTypesOrDirectives . forEach ( newTypeOrDirective => { if ( graphql . isNamedType ( newTypeOrDirective ) ) { originalTypeMap [ newTypeOrDirective . name ] = newTypeOrDirective ; } else if ( graphql . isDirective ( newTypeOrDirective ) ) { originalDirectiveMap [ newTypeOrDirective . name ] = newTypeOrDirective ; } } ) ; const { typeMap , directives } = rewireTypes ( originalTypeMap , Object . keys ( originalDirectiveMap ) . map ( directiveName => originalDirectiveMap [ directiveName ] ) ) ; return new graphql . GraphQLSchema ( { ... config , query : queryTypeName ? typeMap [ queryTypeName ] : undefined , mutation : mutationTypeName ? typeMap [ mutationTypeName ] : undefined , subscription : subscriptionTypeName != null ? typeMap [ subscriptionTypeName ] : undefined , types : Object . keys ( typeMap ) . map ( typeName => typeMap [ typeName ] ) , directives , } ) ; }
addTypes uses toConfig to create a new schema with a new or replaced
addTypes uses toConfig to create a new schema with a new or replaced