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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import graphql.PublicApi;
import org.jspecify.annotations.NullMarked;

import java.util.List;

Expand All @@ -11,6 +12,7 @@
* @param <T> for two
*/
@PublicApi
@NullMarked
public interface ImplementingTypeDefinition<T extends TypeDefinition> extends TypeDefinition<T> {

List<Type> getImplements();
Expand Down
25 changes: 15 additions & 10 deletions src/main/java/graphql/language/InlineFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import graphql.collect.ImmutableKit;
import graphql.util.TraversalControl;
import graphql.util.TraverserContext;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.NullUnmarked;
import org.jspecify.annotations.Nullable;

import java.util.ArrayList;
import java.util.LinkedHashMap;
Expand All @@ -20,8 +23,9 @@
import static graphql.language.NodeChildrenContainer.newNodeChildrenContainer;

@PublicApi
@NullMarked
public class InlineFragment extends AbstractNode<InlineFragment> implements Selection<InlineFragment>, SelectionSetContainer<InlineFragment>, DirectivesContainer<InlineFragment> {
private final TypeName typeCondition;
private final @Nullable TypeName typeCondition;
private final NodeUtil.DirectivesHolder directives;
private final SelectionSet selectionSet;

Expand All @@ -30,10 +34,10 @@ public class InlineFragment extends AbstractNode<InlineFragment> implements Sele
public static final String CHILD_SELECTION_SET = "selectionSet";

@Internal
protected InlineFragment(TypeName typeCondition,
protected InlineFragment(@Nullable TypeName typeCondition,
List<Directive> directives,
SelectionSet selectionSet,
SourceLocation sourceLocation,
@Nullable SourceLocation sourceLocation,
List<Comment> comments,
IgnoredChars ignoredChars,
Map<String, String> additionalData) {
Expand All @@ -48,8 +52,8 @@ protected InlineFragment(TypeName typeCondition,
*
* @param typeCondition the type condition of the inline fragment
*/
public InlineFragment(TypeName typeCondition) {
this(typeCondition, emptyList(), null, null, emptyList(), IgnoredChars.EMPTY, emptyMap());
public InlineFragment(@Nullable TypeName typeCondition) {
this(typeCondition, emptyList(), SelectionSet.newSelectionSet().build(), null, emptyList(), IgnoredChars.EMPTY, emptyMap());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is technically a breaking change, although it's to make this more correct

An inline fragment should not have an empty selection set, as per the specification.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair ... I think we should not allow null selection set here.

}

/**
Expand All @@ -58,11 +62,11 @@ public InlineFragment(TypeName typeCondition) {
* @param typeCondition the type condition of the inline fragment
* @param selectionSet of the inline fragment
*/
public InlineFragment(TypeName typeCondition, SelectionSet selectionSet) {
public InlineFragment(@Nullable TypeName typeCondition, SelectionSet selectionSet) {
this(typeCondition, emptyList(), selectionSet, null, emptyList(), IgnoredChars.EMPTY, emptyMap());
}

public TypeName getTypeCondition() {
public @Nullable TypeName getTypeCondition() {
return typeCondition;
}

Expand Down Expand Up @@ -121,7 +125,7 @@ public InlineFragment withNewChildren(NodeChildrenContainer newChildren) {
}

@Override
public boolean isEqualTo(Node o) {
public boolean isEqualTo(@Nullable Node o) {
if (this == o) {
return true;
}
Expand All @@ -132,8 +136,8 @@ public boolean isEqualTo(Node o) {
public InlineFragment deepCopy() {
return new InlineFragment(
deepCopy(typeCondition),
deepCopy(directives.getDirectives()),
deepCopy(selectionSet),
assertNotNull(deepCopy(directives.getDirectives()), "directives cannot be null"),
assertNotNull(deepCopy(selectionSet), "selectionSet cannot be null"),
getSourceLocation(),
getComments(),
getIgnoredChars(),
Expand Down Expand Up @@ -164,6 +168,7 @@ public InlineFragment transform(Consumer<Builder> builderConsumer) {
return builder.build();
}

@NullUnmarked
public static final class Builder implements NodeDirectivesBuilder {
private SourceLocation sourceLocation;
private ImmutableList<Comment> comments = emptyList();
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/graphql/language/InputObjectTypeDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import graphql.util.FpKit;
import graphql.util.TraversalControl;
import graphql.util.TraverserContext;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.NullUnmarked;
import org.jspecify.annotations.Nullable;

import java.util.LinkedHashMap;
import java.util.List;
Expand All @@ -19,6 +22,7 @@
import static graphql.language.NodeChildrenContainer.newNodeChildrenContainer;

@PublicApi
@NullMarked
public class InputObjectTypeDefinition extends AbstractDescribedNode<InputObjectTypeDefinition> implements TypeDefinition<InputObjectTypeDefinition>, DirectivesContainer<InputObjectTypeDefinition>, NamedNode<InputObjectTypeDefinition> {

private final String name;
Expand All @@ -32,8 +36,8 @@ public class InputObjectTypeDefinition extends AbstractDescribedNode<InputObject
protected InputObjectTypeDefinition(String name,
List<Directive> directives,
List<InputValueDefinition> inputValueDefinitions,
Description description,
SourceLocation sourceLocation,
@Nullable Description description,
@Nullable SourceLocation sourceLocation,
List<Comment> comments,
IgnoredChars ignoredChars,
Map<String, String> additionalData) {
Expand Down Expand Up @@ -94,7 +98,7 @@ public InputObjectTypeDefinition withNewChildren(NodeChildrenContainer newChildr
}

@Override
public boolean isEqualTo(Node o) {
public boolean isEqualTo(@Nullable Node o) {
if (this == o) {
return true;
}
Expand All @@ -110,8 +114,8 @@ public boolean isEqualTo(Node o) {
@Override
public InputObjectTypeDefinition deepCopy() {
return new InputObjectTypeDefinition(name,
deepCopy(directives.getDirectives()),
deepCopy(inputValueDefinitions),
assertNotNull(deepCopy(directives.getDirectives()), "directives cannot be null"),
assertNotNull(deepCopy(inputValueDefinitions), "inputValueDefinitions cannot be null"),
description,
getSourceLocation(),
getComments(),
Expand Down Expand Up @@ -144,6 +148,7 @@ public InputObjectTypeDefinition transform(Consumer<Builder> builderConsumer) {
return builder.build();
}

@NullUnmarked
public static final class Builder implements NodeDirectivesBuilder {
private SourceLocation sourceLocation;
private ImmutableList<Comment> comments = emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import graphql.Internal;
import graphql.PublicApi;
import graphql.collect.ImmutableKit;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.NullUnmarked;
import org.jspecify.annotations.Nullable;

import java.util.LinkedHashMap;
import java.util.List;
Expand All @@ -14,14 +17,15 @@
import static graphql.collect.ImmutableKit.emptyList;

@PublicApi
@NullMarked
public class InputObjectTypeExtensionDefinition extends InputObjectTypeDefinition implements SDLExtensionDefinition {

@Internal
protected InputObjectTypeExtensionDefinition(String name,
List<Directive> directives,
List<InputValueDefinition> inputValueDefinitions,
Description description,
SourceLocation sourceLocation,
@Nullable Description description,
@Nullable SourceLocation sourceLocation,
List<Comment> comments,
IgnoredChars ignoredChars,
Map<String, String> additionalData) {
Expand All @@ -31,8 +35,8 @@ protected InputObjectTypeExtensionDefinition(String name,
@Override
public InputObjectTypeExtensionDefinition deepCopy() {
return new InputObjectTypeExtensionDefinition(getName(),
deepCopy(getDirectives()),
deepCopy(getInputValueDefinitions()),
assertNotNull(deepCopy(getDirectives()), "directives cannot be null"),
assertNotNull(deepCopy(getInputValueDefinitions()), "inputValueDefinitions cannot be null"),
getDescription(),
getSourceLocation(),
getComments(),
Expand Down Expand Up @@ -67,6 +71,7 @@ public InputObjectTypeExtensionDefinition transformExtension(Consumer<Builder> b
return builder.build();
}

@NullUnmarked
public static final class Builder implements NodeDirectivesBuilder {
private SourceLocation sourceLocation;
private ImmutableList<Comment> comments = emptyList();
Expand Down
23 changes: 14 additions & 9 deletions src/main/java/graphql/language/InputValueDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import graphql.collect.ImmutableKit;
import graphql.util.TraversalControl;
import graphql.util.TraverserContext;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.NullUnmarked;
import org.jspecify.annotations.Nullable;

import java.util.ArrayList;
import java.util.LinkedHashMap;
Expand All @@ -21,10 +24,11 @@
import static graphql.language.NodeChildrenContainer.newNodeChildrenContainer;

@PublicApi
@NullMarked
public class InputValueDefinition extends AbstractDescribedNode<InputValueDefinition> implements DirectivesContainer<InputValueDefinition>, NamedNode<InputValueDefinition> {
private final String name;
private final Type type;
private final Value defaultValue;
private final @Nullable Value defaultValue;
private final NodeUtil.DirectivesHolder directives;

public static final String CHILD_TYPE = "type";
Expand All @@ -34,10 +38,10 @@ public class InputValueDefinition extends AbstractDescribedNode<InputValueDefini
@Internal
protected InputValueDefinition(String name,
Type type,
Value defaultValue,
@Nullable Value defaultValue,
List<Directive> directives,
Description description,
SourceLocation sourceLocation,
@Nullable Description description,
@Nullable SourceLocation sourceLocation,
List<Comment> comments,
IgnoredChars ignoredChars,
Map<String, String> additionalData) {
Expand Down Expand Up @@ -70,7 +74,7 @@ public InputValueDefinition(String name,

public InputValueDefinition(String name,
Type type,
Value defaultValue) {
@Nullable Value defaultValue) {
this(name, type, defaultValue, emptyList(), null, null, emptyList(), IgnoredChars.EMPTY, emptyMap());

}
Expand All @@ -84,7 +88,7 @@ public String getName() {
return name;
}

public Value getDefaultValue() {
public @Nullable Value getDefaultValue() {
return defaultValue;
}

Expand Down Expand Up @@ -139,7 +143,7 @@ public InputValueDefinition withNewChildren(NodeChildrenContainer newChildren) {
}

@Override
public boolean isEqualTo(Node o) {
public boolean isEqualTo(@Nullable Node o) {
if (this == o) {
return true;
}
Expand All @@ -155,9 +159,9 @@ public boolean isEqualTo(Node o) {
@Override
public InputValueDefinition deepCopy() {
return new InputValueDefinition(name,
deepCopy(type),
assertNotNull(deepCopy(type), "type cannot be null"),
deepCopy(defaultValue),
deepCopy(directives.getDirectives()),
assertNotNull(deepCopy(directives.getDirectives()), "directives cannot be null"),
description,
getSourceLocation(),
getComments(),
Expand Down Expand Up @@ -190,6 +194,7 @@ public InputValueDefinition transform(Consumer<Builder> builderConsumer) {
return builder.build();
}

@NullUnmarked
public static final class Builder implements NodeDirectivesBuilder {
private SourceLocation sourceLocation;
private ImmutableList<Comment> comments = emptyList();
Expand Down
17 changes: 11 additions & 6 deletions src/main/java/graphql/language/InterfaceTypeDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import graphql.collect.ImmutableKit;
import graphql.util.TraversalControl;
import graphql.util.TraverserContext;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.NullUnmarked;
import org.jspecify.annotations.Nullable;

import java.util.ArrayList;
import java.util.LinkedHashMap;
Expand All @@ -21,6 +24,7 @@
import static graphql.language.NodeChildrenContainer.newNodeChildrenContainer;

@PublicApi
@NullMarked
public class InterfaceTypeDefinition extends AbstractDescribedNode<InterfaceTypeDefinition> implements ImplementingTypeDefinition<InterfaceTypeDefinition>, DirectivesContainer<InterfaceTypeDefinition>, NamedNode<InterfaceTypeDefinition> {

private final String name;
Expand All @@ -37,8 +41,8 @@ protected InterfaceTypeDefinition(String name,
List<Type> implementz,
List<FieldDefinition> definitions,
List<Directive> directives,
Description description,
SourceLocation sourceLocation,
@Nullable Description description,
@Nullable SourceLocation sourceLocation,
List<Comment> comments,
IgnoredChars ignoredChars,
Map<String, String> additionalData) {
Expand Down Expand Up @@ -121,7 +125,7 @@ public InterfaceTypeDefinition withNewChildren(NodeChildrenContainer newChildren
}

@Override
public boolean isEqualTo(Node o) {
public boolean isEqualTo(@Nullable Node o) {
if (this == o) {
return true;
}
Expand All @@ -137,9 +141,9 @@ public boolean isEqualTo(Node o) {
@Override
public InterfaceTypeDefinition deepCopy() {
return new InterfaceTypeDefinition(name,
deepCopy(implementz),
deepCopy(definitions),
deepCopy(directives.getDirectives()),
assertNotNull(deepCopy(implementz), "implementz cannot be null"),
assertNotNull(deepCopy(definitions), "definitions cannot be null"),
assertNotNull(deepCopy(directives.getDirectives()), "directives cannot be null"),
description,
getSourceLocation(),
getComments(),
Expand Down Expand Up @@ -173,6 +177,7 @@ public InterfaceTypeDefinition transform(Consumer<Builder> builderConsumer) {
return builder.build();
}

@NullUnmarked
public static final class Builder implements NodeDirectivesBuilder {
private SourceLocation sourceLocation;
private ImmutableList<Comment> comments = emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import graphql.Internal;
import graphql.PublicApi;
import graphql.collect.ImmutableKit;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.NullUnmarked;
import org.jspecify.annotations.Nullable;

import java.util.LinkedHashMap;
import java.util.List;
Expand All @@ -14,15 +17,16 @@
import static graphql.collect.ImmutableKit.emptyList;

@PublicApi
@NullMarked
public class InterfaceTypeExtensionDefinition extends InterfaceTypeDefinition implements SDLExtensionDefinition {

@Internal
protected InterfaceTypeExtensionDefinition(String name,
List<Type> implementz,
List<FieldDefinition> definitions,
List<Directive> directives,
Description description,
SourceLocation sourceLocation,
@Nullable Description description,
@Nullable SourceLocation sourceLocation,
List<Comment> comments,
IgnoredChars ignoredChars,
Map<String, String> additionalData) {
Expand All @@ -33,8 +37,8 @@ protected InterfaceTypeExtensionDefinition(String name,
public InterfaceTypeExtensionDefinition deepCopy() {
return new InterfaceTypeExtensionDefinition(getName(),
getImplements(),
deepCopy(getFieldDefinitions()),
deepCopy(getDirectives()),
assertNotNull(deepCopy(getFieldDefinitions()), "fieldDefinitions cannot be null"),
assertNotNull(deepCopy(getDirectives()), "directives cannot be null"),
getDescription(),
getSourceLocation(),
getComments(),
Expand Down Expand Up @@ -70,6 +74,7 @@ public InterfaceTypeExtensionDefinition transformExtension(Consumer<Builder> bui
return builder.build();
}

@NullUnmarked
public static final class Builder implements NodeDirectivesBuilder {
private SourceLocation sourceLocation;
private ImmutableList<Comment> comments = emptyList();
Expand Down
Loading