@Override public <T> T getBeanByType(final Class<T> objectClass) { return retrieveBean(objectClass, null); }
public Object invokeMethodByName(DfsContext dfsContext, Class<?> implClass, String methodName, Object... args) { Object defaultValue = null; if (StringUtils.hasText(methodName)) { Object object = null; if (getGraphQLSchemaBeanFactory().containsBean(implClass)) object = getGraphQLSchemaBeanFactory().getBeanByType(implClass); Method defaultValueProviderMethod = args == null ? org.springframework.util.ReflectionUtils.findMethod(implClass, methodName) : org.springframework.util.ReflectionUtils.findMethod(implClass, methodName, getArgumentClasses(args)); if (defaultValueProviderMethod != null) { defaultValue = org.springframework.util.ReflectionUtils.invokeMethod(defaultValueProviderMethod, object, args); } } return defaultValue; }
public GraphQLSchemaHolder getGraphQLSchemaHolder(final String schemaName) { Assert.assertNotNull(schemaName, "Schema name can not be null"); return containsSchema(schemaName) ? graphQLSchemaHolders.get(schemaName) : getSingleSchema(); }
ResolvableTypeAccessor.forMethodReturnType(method, implClass); if (methodReturnTypeResolvableTypeAccessor.isGraphQLMutation()) { String beanName = implClass.getName() + methodReturnTypeResolvableTypeAccessor.getName(); Object object = getGraphQLSchemaBeanFactory().getBeanByType(implClass); String mutationName = StereotypeUtils.getGraphQLMutationName(method, methodReturnTypeResolvableTypeAccessor.getName()); GraphQLObjectType graphQLOutputObjectType = createGraphQLOutputObjectType(dfsContext, mutationName, methodReturnTypeResolvableTypeAccessor); GraphQLInputType graphQLInputType = createGraphQLInputObjectType(dfsContext, mutationName, method, implClass); .description(methodReturnTypeResolvableTypeAccessor.getDescription()) .deprecate(methodReturnTypeResolvableTypeAccessor.getGraphQLDeprecationReason()) .type(graphQLOutputObjectType) .dataFetcher(new ReflectionGraphQLDataMutator(graphQLSchemaConfig, object, method)); .name(getGraphQLSchemaConfig().getMutationInputArgumentName()) .type(graphQLInputType) .build()); addToFieldDefinitionResolverMap(dfsContext, mutationField, methodReturnTypeResolvableTypeAccessor.getGraphQLComplexitySpelExpression()); graphQLFieldDefinitions.add(mutationField);
public GraphQLFieldDefinition getMethodDefinition(DfsContext dfsContext, Class<?> objectClass, Method method) { GraphQLFieldDefinition graphQLFieldDefinition = null; ResolvableTypeAccessor resolvableTypeAccessor = ResolvableTypeAccessor.forMethodReturnType(method, objectClass); if (resolvableTypeAccessor.isGraphQLIdOrGraphQLField()) { GraphQLOutputType graphQLOutputType = (GraphQLOutputType) createGraphQLFieldType(dfsContext, resolvableTypeAccessor, true); List<GraphQLArgument> graphQLArguments = buildGraphQLArgumentsFromMethodParams(dfsContext, method, objectClass); GraphQLFieldDefinition.Builder builder = GraphQLFieldDefinition .newFieldDefinition() .name(resolvableTypeAccessor.getName()) .deprecate(resolvableTypeAccessor.getGraphQLDeprecationReason()) .argument(graphQLArguments) .type(graphQLOutputType) .description(resolvableTypeAccessor.getDescription()); if (!objectClass.isInterface()) { String beanName = objectClass.getName() + resolvableTypeAccessor.getName(); Object object = getGraphQLSchemaBeanFactory().getBeanByType(objectClass); builder.dataFetcher(new ReflectionGraphQLDataFetcher(getGraphQLSchemaConfig(), object, method)); } graphQLFieldDefinition = builder.build(); addToFieldDefinitionResolverMap(dfsContext, graphQLFieldDefinition, resolvableTypeAccessor.getGraphQLComplexitySpelExpression()); } return graphQLFieldDefinition; }
@Bean public GraphQLSchemaBeanFactory graphQLSchemaBeanFactory() { return new SpringGraphQLSchemaBeanFactory(); }
public GraphQLSchemaHolder getSingleSchema() { return getTotalNumberOfSchemas() == 1 ? graphQLSchemaHolders.get(graphQLSchemaHolders.keySet().iterator().next()) : null; }
@Bean public GraphQLSchemaBeanFactory graphQLSchemaBeanFactory() { return new SpringGraphQLSchemaBeanFactory(); }
@Override public <T> T getBeanByName(final String beanName) { return retrieveBean(null, beanName); }
@Bean public GraphQLSchemaBeanFactory graphQLSchemaBeanFactory() { return new SpringGraphQLSchemaBeanFactory(); }
@Bean public GraphQLSchemaBeanFactory graphQLSchemaBeanFactory() { return new SpringGraphQLSchemaBeanFactory(); }