Skip to content
Merged
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
5 changes: 3 additions & 2 deletions src/main/java/graphql/language/Field.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import graphql.Internal;
import graphql.PublicApi;
import graphql.collect.ImmutableKit;
import graphql.util.FieldNameInterner;
import graphql.util.TraversalControl;
import graphql.util.TraverserContext;

Expand Down Expand Up @@ -50,8 +51,8 @@ protected Field(String name,
IgnoredChars ignoredChars,
Map<String, String> additionalData) {
super(sourceLocation, comments, ignoredChars, additionalData);
this.name = name;
this.alias = alias;
this.name = name == null ? null : FieldNameInterner.intern(name);
this.alias = alias == null ? null : FieldNameInterner.intern(alias);
this.arguments = ImmutableList.copyOf(arguments);
this.directives = ImmutableList.copyOf(directives);
this.selectionSet = selectionSet;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/graphql/schema/GraphQLFieldDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import graphql.Internal;
import graphql.PublicApi;
import graphql.language.FieldDefinition;
import graphql.util.FieldNameInterner;
import graphql.util.TraversalControl;
import graphql.util.TraverserContext;

Expand Down Expand Up @@ -61,7 +62,7 @@ private GraphQLFieldDefinition(String name,
assertValidName(name);
assertNotNull(type, () -> "type can't be null");
assertNotNull(arguments, () -> "arguments can't be null");
this.name = name;
this.name = FieldNameInterner.intern(name);
this.description = description;
this.originalType = type;
this.dataFetcherFactory = dataFetcherFactory;
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/graphql/schema/GraphQLInterfaceType.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public class GraphQLInterfaceType implements GraphQLNamedType, GraphQLCompositeT
private final Comparator<? super GraphQLSchemaElement> interfaceComparator;
private ImmutableList<GraphQLNamedOutputType> replacedInterfaces;


public static final String CHILD_FIELD_DEFINITIONS = "fieldDefinitions";
public static final String CHILD_INTERFACES = "interfaces";

Expand Down Expand Up @@ -96,7 +95,6 @@ public GraphQLFieldDefinition getFieldDefinition(String name) {
return fieldDefinitionsByName.get(name);
}


@Override
public List<GraphQLFieldDefinition> getFieldDefinitions() {
return ImmutableList.copyOf(fieldDefinitionsByName.values());
Expand Down Expand Up @@ -229,9 +227,9 @@ public GraphQLInterfaceType withNewChildren(SchemaElementChildrenContainer newCh
@Override
public List<GraphQLNamedOutputType> getInterfaces() {
if (replacedInterfaces != null) {
return ImmutableList.copyOf(replacedInterfaces);
return replacedInterfaces;
}
return ImmutableList.copyOf(originalInterfaces);
return originalInterfaces;
}

void replaceInterfaces(List<GraphQLNamedOutputType> interfaces) {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/graphql/schema/GraphQLObjectType.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
@PublicApi
public class GraphQLObjectType implements GraphQLNamedOutputType, GraphQLCompositeType, GraphQLUnmodifiedType, GraphQLNullableType, GraphQLDirectiveContainer, GraphQLImplementingType {


private final String name;
private final String description;
private final Comparator<? super GraphQLSchemaElement> interfaceComparator;
Expand Down Expand Up @@ -132,7 +131,6 @@ public List<GraphQLFieldDefinition> getFieldDefinitions() {
return ImmutableList.copyOf(fieldDefinitionsByName.values());
}


@Override
public List<GraphQLNamedOutputType> getInterfaces() {
if (replacedInterfaces != null) {
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/graphql/util/FieldNameInterner.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package graphql.util;

import com.google.common.collect.Interner;
import com.google.common.collect.Interners;
import graphql.Internal;

/**
* Interner allowing object identity based comparison of field names.
*/
@Internal
public class FieldNameInterner {

private FieldNameInterner() {
}

public static final Interner<String> INTERNER = Interners.newWeakInterner();

public static String intern(String name) {
return INTERNER.intern(name);
}

}