All Downloads are FREE. Search and download functionalities are using the official Maven repository.

graphql.nadel.schema.UnderlyingSchemaGenerator Maven / Gradle / Ivy

There is a newer version: 2021-03-26T09-09-21-fabd441
Show newest version
package graphql.nadel.schema;

import graphql.Internal;
import graphql.schema.GraphQLSchema;
import graphql.schema.idl.RuntimeWiring;
import graphql.schema.idl.SchemaGenerator;
import graphql.schema.idl.TypeDefinitionRegistry;
import graphql.schema.idl.WiringFactory;
import graphql.schema.idl.errors.SchemaProblem;

import static java.lang.String.format;

@Internal
public class UnderlyingSchemaGenerator {

    public GraphQLSchema buildUnderlyingSchema(String serviceName, TypeDefinitionRegistry underlyingTypeDefinitions, WiringFactory wiringFactory) throws ServiceSchemaProblem {
        SchemaGenerator schemaGenerator = new SchemaGenerator();
        RuntimeWiring runtimeWiring = RuntimeWiring.newRuntimeWiring()
                .wiringFactory(new UnderlyingWiringFactory(wiringFactory))
                .build();
        try {
            return schemaGenerator.makeExecutableSchema(underlyingTypeDefinitions, runtimeWiring);
        } catch (SchemaProblem schemaProblem) {
            String message = format("There was a problem building the schema for '%s' : %s",
                    serviceName, schemaProblem.getMessage());
            throw new ServiceSchemaProblem(message, serviceName, schemaProblem);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy