io.leangen.graphql.GraphQLSchemaGenerator Java Examples

The following examples show how to use io.leangen.graphql.GraphQLSchemaGenerator. 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: BaseAutoConfiguration.java    From graphql-spqr-spring-boot-starter with Apache License 2.0 6 votes vote down vote up
private void addOperationSources(GraphQLSchemaGenerator schemaGenerator, Collection<SpqrBean> spqrBeans) {
    spqrBeans.stream()
            .filter(spqrBean -> spqrBean.getScope().equals(BeanScope.SINGLETON))
            .forEach(
                    spqrBean ->
                            schemaGenerator.withOperationsFromSingleton(
                                    spqrBean.getSpringBean(),
                                    spqrBean.getType(),
                                    spqrBean.resolverBuilders.stream()
                                            .map(resolverBuilderBeanIdentity -> findQualifiedBeanByType(resolverBuilderBeanIdentity.getResolverType(),
                                                    resolverBuilderBeanIdentity.getValue(),
                                                    resolverBuilderBeanIdentity.getQualifierType()))
                                            .toArray(ResolverBuilder[]::new)
                            )
            );
}
 
Example #2
Source File: GraphQLFactory.java    From micronaut-graphql with Apache License 2.0 5 votes vote down vote up
@Bean
@Singleton
public GraphQL graphQL(ToDoService toDoService) {

    // Create the executable schema.
    GraphQLSchema graphQLSchema = new GraphQLSchemaGenerator()
            .withOperationsFromSingleton(toDoService)
            .generate();

    // Return the GraphQL bean.
    return GraphQL.newGraphQL(graphQLSchema).build();
}
 
Example #3
Source File: BaseAutoConfiguration.java    From graphql-spqr-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public GraphQLSchemaGenerator graphQLSchemaGenerator(SpqrProperties spqrProperties) {
    GraphQLSchemaGenerator schemaGenerator = new GraphQLSchemaGenerator();

    schemaGenerator.withBasePackages(spqrProperties.getBasePackages());

    if (spqrProperties.getRelay().isEnabled()) {
        if (!StringUtils.isEmpty(spqrProperties.getRelay().getMutationWrapper())) {
            schemaGenerator.withRelayCompliantMutations(
                    spqrProperties.getRelay().getMutationWrapper(), spqrProperties.getRelay().getMutationWrapperDescription()
            );
        } else {
            schemaGenerator.withRelayCompliantMutations();
        }
    }

    Map<String, SpqrBean> beansWiredAsComponent = findGraphQLApiComponents();
    addOperationSources(schemaGenerator, beansWiredAsComponent.values());

    List<SpqrBean> beansWiredWithAsBeans = findGraphQLApiBeans();
    addOperationSources(schemaGenerator, beansWiredWithAsBeans);

    // Modules should be registered first, so that extension providers have a chance to override what they need
    // Built-in modules must go before the user-provided ones for similar reasons
    if (internalModules != null) {
        internalModules.forEach(module -> schemaGenerator.withModules(module.get()));
    }

    if (moduleExtensionProvider != null) {
        schemaGenerator.withModules(moduleExtensionProvider);
    }

    if (globalResolverBuilderExtensionProvider != null) {
        schemaGenerator.withResolverBuilders(globalResolverBuilderExtensionProvider);
    }

    if (typeMapperExtensionProvider != null) {
        schemaGenerator.withTypeMappers(typeMapperExtensionProvider);
    }

    if (inputConverterExtensionProvider != null) {
        schemaGenerator.withInputConverters(inputConverterExtensionProvider);
    }

    if (outputConverterExtensionProvider != null) {
        schemaGenerator.withOutputConverters(outputConverterExtensionProvider);
    }

    if (argumentInjectorExtensionProvider != null) {
        schemaGenerator.withArgumentInjectors(argumentInjectorExtensionProvider);
    }

    if (schemaTransformerExtensionProvider != null) {
        schemaGenerator.withSchemaTransformers(schemaTransformerExtensionProvider);
    }

    if (resolverInterceptorFactoryExtensionProvider != null) {
        schemaGenerator.withResolverInterceptorFactories(resolverInterceptorFactoryExtensionProvider);
    }

    if (valueMapperFactory != null) {
        schemaGenerator.withValueMapperFactory(valueMapperFactory);
    }

    if (inputFieldBuilderProvider != null) {
        schemaGenerator.withInputFieldBuilders(inputFieldBuilderProvider);
    }

    if (typeInfoGenerator != null) {
        schemaGenerator.withTypeInfoGenerator(typeInfoGenerator);
    }

    if (spqrProperties.isAbstractInputTypeResolution()) {
        schemaGenerator.withAbstractInputTypeResolution();
    }

    if (abstractInputHandler != null) {
        schemaGenerator.withAbstractInputHandler(abstractInputHandler);
    }

    if (messageBundles != null && !messageBundles.isEmpty()) {
        schemaGenerator.withStringInterpolation(messageBundles.toArray(new MessageBundle[0]));
    }

    if (inclusionStrategy != null) {
        schemaGenerator.withInclusionStrategy(inclusionStrategy);
    }

    if (interfaceMappingStrategy != null) {
        schemaGenerator.withInterfaceMappingStrategy(interfaceMappingStrategy);
    }

    if (spqrProperties.getRelay().isConnectionCheckRelaxed()) {
        schemaGenerator.withRelayConnectionCheckRelaxed();
    }

    return schemaGenerator;
}
 
Example #4
Source File: BaseAutoConfiguration.java    From graphql-spqr-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public GraphQLSchema graphQLSchema(GraphQLSchemaGenerator schemaGenerator) {
    return schemaGenerator.generate();
}
 
Example #5
Source File: Module.java    From graphql-spqr with Apache License 2.0 votes vote down vote up
GraphQLSchemaGenerator getSchemaGenerator();