public GraphQLObjectType findSchemaMutations(DfsContext dfsContext, Class<?> implClass) { List<GraphQLFieldDefinition> graphQLFieldDefinitions = findSchemaMutationsFields(dfsContext, implClass); return newObject() .name(getGraphQLSchemaConfig().getSchemaMutationObjectName()) .fields(graphQLFieldDefinitions) .build(); }
public GraphQLObjectType createGraphQLOutputObjectType(DfsContext dfsContext, String mutationName, ResolvableTypeAccessor resolvableTypeAccessor) { Class<?> cls = resolvableTypeAccessor.resolve(); GraphQLType graphQLObjectType = objectTypeResolverMap.get(cls); if (graphQLObjectType == null) graphQLObjectType = createGraphQLFieldType(dfsContext, resolvableTypeAccessor, true); GraphQLOutputType clientMutationIdType = getGraphQLSchemaConfig().isAllowEmptyClientMutationId() ? GraphQLString : new GraphQLNonNull(GraphQLString); addToMutationReturnTypeResolverMap(dfsContext, mutationName, cls, (GraphQLOutputType) graphQLObjectType); GraphQLFieldDefinition graphQLFieldDefinition = newFieldDefinition() .name(resolvableTypeAccessor.getGraphQLOutName()) .deprecate(resolvableTypeAccessor.getGraphQLDeprecationReason()) .description(resolvableTypeAccessor.getDescription()) .type((GraphQLOutputType) graphQLObjectType) .build(); addToFieldDefinitionResolverMap(dfsContext, graphQLFieldDefinition, resolvableTypeAccessor.getGraphQLComplexitySpelExpression()); return newObject() .name(resolvableTypeAccessor.getName() + getGraphQLSchemaConfig().getOutputObjectNamePrefix()) .field(newFieldDefinition() .name(getGraphQLSchemaConfig().getClientMutationIdName()) .type(clientMutationIdType) .build()) .field(graphQLFieldDefinition) .build(); }
GraphQLInputType clientMutationIdType = getGraphQLSchemaConfig().isAllowEmptyClientMutationId() ? GraphQLString : new GraphQLNonNull(GraphQLString); .name(inputObjectName + getGraphQLSchemaConfig().getInputObjectNamePrefix()) .field(newInputObjectField() .name(getGraphQLSchemaConfig().getClientMutationIdName()) .type(clientMutationIdType) .build())
.name(getGraphQLSchemaConfig().getMutationInputArgumentName()) .type(graphQLInputType) .build());
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; }