Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/main/java/graphql/execution/ExecutionContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,6 @@ public OperationDefinition getOperationDefinition() {
return operationDefinition;
}

/**
* @return map of coerced variables
*
* @deprecated use {@link #getCoercedVariables()} instead
*/
@Deprecated(since = "2022-05-24")
public Map<String, Object> getVariables() {
return coercedVariables.toMap();
}

public CoercedVariables getCoercedVariables() {
return coercedVariables;
}
Expand Down
18 changes: 7 additions & 11 deletions src/main/java/graphql/relay/Relay.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/**
* This can be used to compose graphql runtime types that implement
* that Relay specification.
*
* <p>
* See <a href="https://facebook.github.io/relay/graphql/connections.htm">https://facebook.github.io/relay/graphql/connections.htm</a>
*/
@PublicApi
Expand Down Expand Up @@ -61,24 +61,22 @@ public class Relay {
.description("When paginating forwards, the cursor to continue."))
.build();

public GraphQLInterfaceType nodeInterface(TypeResolver typeResolver) {
public GraphQLInterfaceType nodeInterface() {
return newInterface()
.name(NODE)
.description("An object with an ID")
.typeResolver(typeResolver)
.field(newFieldDefinition()
.name("id")
.description("The ID of an object")
.type(nonNull(GraphQLID)))
.build();
}

public GraphQLFieldDefinition nodeField(GraphQLInterfaceType nodeInterface, DataFetcher nodeDataFetcher) {
public GraphQLFieldDefinition nodeField(GraphQLInterfaceType nodeInterface) {
return newFieldDefinition()
.name("node")
.description("Fetches an object given its ID")
.type(nodeInterface)
.dataFetcher(nodeDataFetcher)
.argument(newArgument()
.name("id")
.description("The ID of an object")
Expand Down Expand Up @@ -175,8 +173,8 @@ public GraphQLObjectType connectionType(String name, GraphQLObjectType edgeType,

public GraphQLFieldDefinition mutationWithClientMutationId(String name, String fieldName,
List<GraphQLInputObjectField> inputFields,
List<GraphQLFieldDefinition> outputFields,
DataFetcher dataFetcher) {
List<GraphQLFieldDefinition> outputFields
) {
GraphQLInputObjectField clientMutationIdInputField = newInputObjectField()
.name("clientMutationId")
.type(GraphQLString)
Expand All @@ -187,7 +185,7 @@ public GraphQLFieldDefinition mutationWithClientMutationId(String name, String f
.build();

return mutation(name, fieldName, addElementToList(inputFields, clientMutationIdInputField),
addElementToList(outputFields, clientMutationIdPayloadField), dataFetcher);
addElementToList(outputFields, clientMutationIdPayloadField));
}

private static <T> List<T> addElementToList(List<T> list, T element) {
Expand All @@ -198,8 +196,7 @@ private static <T> List<T> addElementToList(List<T> list, T element) {

public GraphQLFieldDefinition mutation(String name, String fieldName,
List<GraphQLInputObjectField> inputFields,
List<GraphQLFieldDefinition> outputFields,
DataFetcher dataFetcher) {
List<GraphQLFieldDefinition> outputFields) {
GraphQLInputObjectType inputObjectType = newInputObject()
.name(name + "Input")
.fields(inputFields)
Expand All @@ -215,7 +212,6 @@ public GraphQLFieldDefinition mutation(String name, String fieldName,
.argument(newArgument()
.name("input")
.type(nonNull(inputObjectType)))
.dataFetcher(dataFetcher)
.build();
}

Expand Down
15 changes: 0 additions & 15 deletions src/main/java/graphql/schema/CodeRegistryVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,18 @@ public CodeRegistryVisitor(GraphQLCodeRegistry.Builder codeRegistry) {

@Override
public TraversalControl visitGraphQLFieldDefinition(GraphQLFieldDefinition node, TraverserContext<GraphQLSchemaElement> context) {
GraphQLFieldsContainer parentContainerType = (GraphQLFieldsContainer) context.getParentContext().thisNode();
DataFetcher<?> dataFetcher = node.getDataFetcher();
if (dataFetcher != null) {
FieldCoordinates coordinates = coordinates(parentContainerType, node);
codeRegistry.dataFetcherIfAbsent(coordinates, dataFetcher);
}

return CONTINUE;
}

@Override
public TraversalControl visitGraphQLInterfaceType(GraphQLInterfaceType node, TraverserContext<GraphQLSchemaElement> context) {
TypeResolver typeResolver = node.getTypeResolver();
if (typeResolver != null) {
codeRegistry.typeResolverIfAbsent(node, typeResolver);
}
assertTrue(codeRegistry.getTypeResolver(node) != null,
() -> String.format("You MUST provide a type resolver for the interface type '%s'", node.getName()));
return CONTINUE;
}

@Override
public TraversalControl visitGraphQLUnionType(GraphQLUnionType node, TraverserContext<GraphQLSchemaElement> context) {
TypeResolver typeResolver = node.getTypeResolver();
if (typeResolver != null) {
codeRegistry.typeResolverIfAbsent(node, typeResolver);
}
assertTrue(codeRegistry.getTypeResolver(node) != null,
() -> String.format("You MUST provide a type resolver for the union type '%s'", node.getName()));
return CONTINUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static Builder newDataFetchingEnvironment(ExecutionContext executionConte
.locale(executionContext.getLocale())
.document(executionContext.getDocument())
.operationDefinition(executionContext.getOperationDefinition())
.variables(executionContext.getVariables())
.variables(executionContext.getCoercedVariables().toMap())
.executionId(executionContext.getExecutionId());
}

Expand Down
6 changes: 0 additions & 6 deletions src/main/java/graphql/schema/GraphQLCodeRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,12 @@ public TypeResolver getTypeResolver(GraphQLUnionType unionType) {
private static TypeResolver getTypeResolverForInterface(GraphQLInterfaceType parentType, Map<String, TypeResolver> typeResolverMap) {
assertNotNull(parentType);
TypeResolver typeResolver = typeResolverMap.get(parentType.getName());
if (typeResolver == null) {
typeResolver = parentType.getTypeResolver();
}
return assertNotNull(typeResolver, () -> "There must be a type resolver for interface " + parentType.getName());
}

private static TypeResolver getTypeResolverForUnion(GraphQLUnionType parentType, Map<String, TypeResolver> typeResolverMap) {
assertNotNull(parentType);
TypeResolver typeResolver = typeResolverMap.get(parentType.getName());
if (typeResolver == null) {
typeResolver = parentType.getTypeResolver();
}
return assertNotNull(typeResolver, () -> "There must be a type resolver for union " + parentType.getName());
}

Expand Down
82 changes: 1 addition & 81 deletions src/main/java/graphql/schema/GraphQLFieldDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import static graphql.Assert.assertNotNull;
import static graphql.Assert.assertValidName;
import static graphql.schema.DataFetcherFactoryEnvironment.newDataFetchingFactoryEnvironment;
import static graphql.util.FpKit.getByName;

/**
Expand All @@ -37,7 +36,6 @@ public class GraphQLFieldDefinition implements GraphQLNamedSchemaElement, GraphQ
private final String name;
private final String description;
private final GraphQLOutputType originalType;
private final DataFetcherFactory dataFetcherFactory;
private final String deprecationReason;
private final ImmutableList<GraphQLArgument> arguments;
private final DirectivesUtil.DirectivesHolder directivesHolder;
Expand All @@ -52,7 +50,6 @@ public class GraphQLFieldDefinition implements GraphQLNamedSchemaElement, GraphQ
private GraphQLFieldDefinition(String name,
String description,
GraphQLOutputType type,
DataFetcherFactory dataFetcherFactory,
List<GraphQLArgument> arguments,
String deprecationReason,
List<GraphQLDirective> directives,
Expand All @@ -64,7 +61,6 @@ private GraphQLFieldDefinition(String name,
this.name = name;
this.description = description;
this.originalType = type;
this.dataFetcherFactory = dataFetcherFactory;
this.arguments = ImmutableList.copyOf(arguments);
this.directivesHolder = new DirectivesUtil.DirectivesHolder(directives, appliedDirectives);
this.deprecationReason = deprecationReason;
Expand All @@ -85,18 +81,6 @@ public GraphQLOutputType getType() {
return replacedType != null ? replacedType : originalType;
}

// to be removed in a future version when all code is in the code registry
@Internal
@Deprecated(since = "2018-12-03")
DataFetcher<?> getDataFetcher() {
if (dataFetcherFactory == null) {
return null;
}
return dataFetcherFactory.get(newDataFetchingFactoryEnvironment()
.fieldDefinition(this)
.build());
}

public GraphQLArgument getArgument(String name) {
for (GraphQLArgument argument : arguments) {
if (argument.getName().equals(name)) {
Expand Down Expand Up @@ -167,7 +151,6 @@ public String toString() {
"name='" + name + '\'' +
", type=" + getType() +
", arguments=" + arguments +
", dataFetcherFactory=" + dataFetcherFactory +
", description='" + description + '\'' +
", deprecationReason='" + deprecationReason + '\'' +
", definition=" + definition +
Expand Down Expand Up @@ -255,10 +238,9 @@ public static Builder newFieldDefinition() {
}

@PublicApi
public static class Builder extends GraphqlDirectivesContainerTypeBuilder<Builder,Builder> {
public static class Builder extends GraphqlDirectivesContainerTypeBuilder<Builder, Builder> {

private GraphQLOutputType type;
private DataFetcherFactory<?> dataFetcherFactory;
private String deprecationReason;
private FieldDefinition definition;
private final Map<String, GraphQLArgument> arguments = new LinkedHashMap<>();
Expand All @@ -270,7 +252,6 @@ public Builder(GraphQLFieldDefinition existing) {
this.name = existing.getName();
this.description = existing.getDescription();
this.type = existing.originalType;
this.dataFetcherFactory = DataFetcherFactories.useDataFetcher(existing.getDataFetcher());
this.deprecationReason = existing.getDeprecationReason();
this.definition = existing.getDefinition();
this.arguments.putAll(getByName(existing.getArguments(), GraphQLArgument::getName));
Expand Down Expand Up @@ -299,52 +280,6 @@ public Builder type(GraphQLOutputType type) {
return this;
}

/**
* Sets the {@link graphql.schema.DataFetcher} to use with this field.
*
* @param dataFetcher the data fetcher to use
*
* @return this builder
*
* @deprecated use {@link graphql.schema.GraphQLCodeRegistry} instead
*/
@Deprecated(since = "2018-12-03")
public Builder dataFetcher(DataFetcher<?> dataFetcher) {
assertNotNull(dataFetcher, () -> "dataFetcher must be not null");
this.dataFetcherFactory = DataFetcherFactories.useDataFetcher(dataFetcher);
return this;
}

/**
* Sets the {@link graphql.schema.DataFetcherFactory} to use with this field.
*
* @param dataFetcherFactory the data fetcher factory
*
* @return this builder
*
* @deprecated use {@link graphql.schema.GraphQLCodeRegistry} instead
*/
@Deprecated(since = "2018-12-03")
public Builder dataFetcherFactory(DataFetcherFactory<?> dataFetcherFactory) {
assertNotNull(dataFetcherFactory, () -> "dataFetcherFactory must be not null");
this.dataFetcherFactory = dataFetcherFactory;
return this;
}

/**
* This will cause the data fetcher of this field to always return the supplied value
*
* @param value the value to always return
*
* @return this builder
*
* @deprecated use {@link graphql.schema.GraphQLCodeRegistry} instead
*/
@Deprecated(since = "2018-12-03")
public Builder staticValue(final Object value) {
this.dataFetcherFactory = DataFetcherFactories.useDataFetcher(environment -> value);
return this;
}

public Builder argument(GraphQLArgument argument) {
assertNotNull(argument, () -> "argument can't be null");
Expand Down Expand Up @@ -384,20 +319,6 @@ public Builder argument(GraphQLArgument.Builder builder) {
return this;
}

/**
* This adds the list of arguments to the field.
*
* @param arguments the arguments to add
*
* @return this
*
* @deprecated This is a badly named method and is replaced by {@link #arguments(java.util.List)}
*/
@Deprecated(since = "2019-02-06")
public Builder argument(List<GraphQLArgument> arguments) {
return arguments(arguments);
}

/**
* This adds the list of arguments to the field.
*
Expand Down Expand Up @@ -480,7 +401,6 @@ public GraphQLFieldDefinition build() {
name,
description,
type,
dataFetcherFactory,
sort(arguments, GraphQLFieldDefinition.class, GraphQLArgument.class),
deprecationReason,
sort(directives, GraphQLFieldDefinition.class, GraphQLDirective.class),
Expand Down
Loading