Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
327559f
Add German validation errors
dondonz Aug 14, 2022
09fdf22
Tidy up IDE error
dondonz Aug 14, 2022
e5f8367
Tidy up
dondonz Aug 14, 2022
7abed8c
Fix word
dondonz Aug 14, 2022
3d8c552
Better words
dondonz Aug 14, 2022
74e4440
Merge branch 'master' into auf-deutsch
dondonz Sep 3, 2022
c01fc27
Make English messages consistent, no full stop at end of message
dondonz Sep 3, 2022
453255f
Add German translations for parsing and scalar messages
dondonz Sep 3, 2022
70e9327
Merge branch 'master' into auf-deutsch
dondonz Oct 16, 2022
448c965
Uncomment Parsing translations
dondonz Oct 16, 2022
304db9a
Merge branch 'master' into auf-deutsch
dondonz Oct 21, 2022
744ebdd
Update after comments
dondonz Oct 21, 2022
2e8e1c4
Update test
dondonz Oct 21, 2022
e5287d6
Fix typo
dondonz Oct 23, 2022
f8d9ade
Update src/main/resources/i18n/Validation_de.properties
dondonz Oct 27, 2022
6335cf0
Float coercion tidy up (#2982)
dondonz Oct 27, 2022
9c359c5
Only run GCP tests on main graphql-java repo (skip on forks).
Oct 27, 2022
be851d7
Merge pull request #2997 from folone/gleontiev/only-run-gcp-workflow-…
andimarek Oct 27, 2022
bb4a3b2
Parameterized introspection queries (#2993)
MayCXC Oct 29, 2022
2de42f4
Update version
dondonz Oct 30, 2022
db79724
Merge pull request #3002 from graphql-java/update-aqute-builder
dondonz Oct 30, 2022
322ba6b
Avoid an allocation of a chained context in the most common case (#2979)
bbakerman Oct 31, 2022
c665248
Polishing (#3001)
dfa1 Oct 31, 2022
71eccd4
Document the new IntrospectionQueryBuilder and tweaked it a little (#…
bbakerman Oct 31, 2022
9787497
LambdaMetafactory support for property fetches (#2985)
bbakerman Oct 31, 2022
13ab000
SchemaGeneratorPostProcessing should be deprecated (#2999)
bbakerman Oct 31, 2022
5c0c68b
Fixes in TwitterBenchmark (#3006)
dfa1 Nov 6, 2022
ae51c2d
applied directives on arguments are not relevant when checked if an i…
andimarek Nov 11, 2022
d194761
Merge pull request #3014 from graphql-java/fix-argument-directives-im…
andimarek Nov 11, 2022
04df386
improve test case by adding a new valid location example
andimarek Nov 12, 2022
df2a717
Adds an error builder on GraphQLError (#3011)
bbakerman Nov 12, 2022
04215b5
Fix grammar
dondonz Nov 13, 2022
e16db8b
Merge pull request #2917 from graphql-java/auf-deutsch
dondonz Nov 13, 2022
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
1 change: 1 addition & 0 deletions .github/workflows/invoke_test_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ env:

jobs:
execute_workflow:
if: github.repository == 'graphql-java/graphql-java'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Thanks for contributing to graphql-java!


Please be sure that you read the [Code of Conduct](CODE_OF_CONDUCT.md) before contributing to this project and please
create a new Issue and discuss first what your are planning to do for bigger changes.
create a new Issue and discuss first what you are planning to do for larger changes.


The overall goal of graphql-java is to have a correct implementation of the [GraphQL Spec](https://github.com/facebook/graphql/) in a production ready way.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
id 'antlr'
id 'signing'
id "com.github.johnrengelman.shadow" version "7.1.2"
id "biz.aQute.bnd.builder" version "6.1.0"
id "biz.aQute.bnd.builder" version "6.3.1"
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
id "groovy"
id "me.champeau.jmh" version "0.6.6"
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/graphql/ErrorClassification.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,21 @@ public interface ErrorClassification {
default Object toSpecification(GraphQLError error) {
return String.valueOf(this);
}

/**
* This produces a simple ErrorClassification that represents the provided String. You can
* use this factory method to give out simple but custom error classifications.
*
* @param errorClassification the string that represents the error classification
*
* @return a ErrorClassification that is that provided string
*/
static ErrorClassification errorClassification(String errorClassification) {
return new ErrorClassification() {
@Override
public String toString() {
return errorClassification;
}
};
}
}
2 changes: 1 addition & 1 deletion src/main/java/graphql/ExecutionResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public interface ExecutionResult {
* should be present. Certain JSON serializers may or may interpret {@link ExecutionResult} to spec, so this method
* is provided to produce a map that strictly follows the specification.
*
* See : <a href="http://facebook.github.io/graphql/#sec-Response-Format">http://facebook.github.io/graphql/#sec-Response-Format</a>
* See : <a href="https://spec.graphql.org/October2021/#sec-Response-Format">https://spec.graphql.org/October2021/#sec-Response-Format</a>
*
* @return a map of the result that strictly follows the spec
*/
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/graphql/GraphQL.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import graphql.execution.instrumentation.InstrumentationContext;
import graphql.execution.instrumentation.InstrumentationState;
import graphql.execution.instrumentation.NoContextChainedInstrumentation;
import graphql.execution.instrumentation.SimpleInstrumentation;
import graphql.execution.instrumentation.SimplePerformantInstrumentation;
import graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentation;
import graphql.execution.instrumentation.parameters.InstrumentationCreateStateParameters;
import graphql.execution.instrumentation.parameters.InstrumentationExecutionParameters;
Expand All @@ -35,7 +35,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
Expand Down Expand Up @@ -575,7 +574,7 @@ private CompletableFuture<ExecutionResult> execute(ExecutionInput executionInput

private static Instrumentation checkInstrumentationDefaultState(Instrumentation instrumentation, boolean doNotAddDefaultInstrumentations) {
if (doNotAddDefaultInstrumentations) {
return instrumentation == null ? SimpleInstrumentation.INSTANCE : instrumentation;
return instrumentation == null ? SimplePerformantInstrumentation.INSTANCE : instrumentation;
}
if (instrumentation instanceof DataLoaderDispatcherInstrumentation) {
return instrumentation;
Expand Down
84 changes: 83 additions & 1 deletion src/main/java/graphql/GraphQLError.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package graphql;


import graphql.execution.ResultPath;
import graphql.language.SourceLocation;
import org.jetbrains.annotations.Nullable;

import java.io.Serializable;
import java.util.List;
Expand Down Expand Up @@ -38,7 +40,7 @@ public interface GraphQLError extends Serializable {

/**
* The graphql spec says that the (optional) path field of any error should be a list
* of path entries - http://facebook.github.io/graphql/#sec-Errors
* of path entries https://spec.graphql.org/October2021/#sec-Handling-Field-Errors
*
* @return the path in list format
*/
Expand Down Expand Up @@ -66,5 +68,85 @@ default Map<String, Object> getExtensions() {
return null;
}

/**
* @return a new builder of {@link GraphQLError}s
*/
static Builder<?> newError() {
return new GraphqlErrorBuilder<>();
}

/**
* A builder of {@link GraphQLError}s
*/
interface Builder<B extends Builder<B>> {

/**
* Sets the message of the error using {@link String#format(String, Object...)} with the arguments
*
* @param message the message
* @param formatArgs the arguments to use
*
* @return this builder
*/
B message(String message, Object... formatArgs);

/**
* This adds locations to the error
*
* @param locations the locations to add
*
* @return this builder
*/
B locations(@Nullable List<SourceLocation> locations);

/**
* This adds a location to the error
*
* @param location the locations to add
*
* @return this builder
*/
B location(@Nullable SourceLocation location);

/**
* Sets the path of the message
*
* @param path can be null
*
* @return this builder
*/
B path(@Nullable ResultPath path);

/**
* Sets the path of the message
*
* @param path can be null
*
* @return this builder
*/
B path(@Nullable List<Object> path);

/**
* Sets the {@link ErrorClassification} of the message
*
* @param errorType the error classification to use
*
* @return this builder
*/
B errorType(ErrorClassification errorType);

/**
* Sets the extensions of the message
*
* @param extensions the extensions to use
*
* @return this builder
*/
B extensions(@Nullable Map<String, Object> extensions);

/**
* @return a newly built GraphqlError
*/
GraphQLError build();
}
}
4 changes: 2 additions & 2 deletions src/main/java/graphql/GraphqlErrorBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import graphql.execution.ResultPath;
import graphql.language.SourceLocation;
import graphql.schema.DataFetchingEnvironment;

import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand All @@ -20,7 +20,7 @@
*/
@SuppressWarnings("unchecked")
@PublicApi
public class GraphqlErrorBuilder<B extends GraphqlErrorBuilder<B>> {
public class GraphqlErrorBuilder<B extends GraphqlErrorBuilder<B>> implements GraphQLError.Builder<B> {

private String message;
private List<Object> path;
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/graphql/Scalars.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,41 @@
* by the graphql specification (Int, Float, String, Boolean and ID) while others are offer because they are common on
* Java platforms.
* <p>
* For more info see http://graphql.org/learn/schema/#scalar-types and more specifically http://facebook.github.io/graphql/#sec-Scalars
* For more info see http://graphql.org/learn/schema/#scalar-types and more specifically https://spec.graphql.org/October2021/#sec-Scalars
*/
@PublicApi
public class Scalars {

/**
* This represents the "Int" type as defined in the graphql specification : http://facebook.github.io/graphql/#sec-Int
* This represents the "Int" type as defined in the graphql specification : https://spec.graphql.org/October2021/#sec-Int
* <p>
* The Int scalar type represents a signed 32‐bit numeric non‐fractional value.
*/
public static final GraphQLScalarType GraphQLInt = GraphQLScalarType.newScalar()
.name("Int").description("Built-in Int").coercing(new GraphqlIntCoercing()).build();

/**
* This represents the "Float" type as defined in the graphql specification : http://facebook.github.io/graphql/#sec-Float
* This represents the "Float" type as defined in the graphql specification : https://spec.graphql.org/October2021/#sec-Float
* <p>
* Note: The Float type in GraphQL is equivalent to Double in Java. (double precision IEEE 754)
*/
public static final GraphQLScalarType GraphQLFloat = GraphQLScalarType.newScalar()
.name("Float").description("Built-in Float").coercing(new GraphqlFloatCoercing()).build();

/**
* This represents the "String" type as defined in the graphql specification : http://facebook.github.io/graphql/#sec-String
* This represents the "String" type as defined in the graphql specification : https://spec.graphql.org/October2021/#sec-String
*/
public static final GraphQLScalarType GraphQLString = GraphQLScalarType.newScalar()
.name("String").description("Built-in String").coercing(new GraphqlStringCoercing()).build();

/**
* This represents the "Boolean" type as defined in the graphql specification : http://facebook.github.io/graphql/#sec-Boolean
* This represents the "Boolean" type as defined in the graphql specification : https://spec.graphql.org/October2021/#sec-Boolean
*/
public static final GraphQLScalarType GraphQLBoolean = GraphQLScalarType.newScalar()
.name("Boolean").description("Built-in Boolean").coercing(new GraphqlBooleanCoercing()).build();

/**
* This represents the "ID" type as defined in the graphql specification : http://facebook.github.io/graphql/#sec-ID
* This represents the "ID" type as defined in the graphql specification : https://spec.graphql.org/October2021/#sec-ID
* <p>
* The ID scalar type represents a unique identifier, often used to re-fetch an object or as the key for a cache. The
* ID type is serialized in the same way as a String; however, it is not intended to be human‐readable. While it is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import graphql.execution.ExecutionContext;
import graphql.execution.instrumentation.InstrumentationContext;
import graphql.execution.instrumentation.InstrumentationState;
import graphql.execution.instrumentation.SimpleInstrumentation;
import graphql.execution.instrumentation.SimplePerformantInstrumentation;
import graphql.execution.instrumentation.parameters.InstrumentationCreateStateParameters;
import graphql.execution.instrumentation.parameters.InstrumentationExecuteOperationParameters;
import graphql.execution.instrumentation.parameters.InstrumentationValidationParameters;
Expand All @@ -22,6 +22,7 @@
import java.util.function.Function;

import static graphql.Assert.assertNotNull;
import static graphql.execution.instrumentation.InstrumentationState.ofState;
import static graphql.execution.instrumentation.SimpleInstrumentationContext.noOp;
import static java.util.Optional.ofNullable;

Expand All @@ -32,7 +33,7 @@
* is exceeded. If the function returns {@code true} a {@link AbortExecutionException} is thrown.
*/
@PublicApi
public class MaxQueryComplexityInstrumentation extends SimpleInstrumentation {
public class MaxQueryComplexityInstrumentation extends SimplePerformantInstrumentation {

private static final Logger log = LoggerFactory.getLogger(MaxQueryComplexityInstrumentation.class);

Expand Down Expand Up @@ -91,15 +92,15 @@ public InstrumentationState createState(InstrumentationCreateStateParameters par

@Override
public @Nullable InstrumentationContext<List<ValidationError>> beginValidation(InstrumentationValidationParameters parameters, InstrumentationState rawState) {
State state = (State) rawState;
State state = ofState(rawState);
// for API backwards compatibility reasons we capture the validation parameters, so we can put them into QueryComplexityInfo
state.instrumentationValidationParameters.set(parameters);
return noOp();
}

@Override
public @Nullable InstrumentationContext<ExecutionResult> beginExecuteOperation(InstrumentationExecuteOperationParameters instrumentationExecuteOperationParameters, InstrumentationState rawState) {
State state = (State) rawState;
State state = ofState(rawState);
QueryTraverser queryTraverser = newQueryTraverser(instrumentationExecuteOperationParameters.getExecutionContext());

Map<QueryVisitorFieldEnvironment, Integer> valuesByParent = new LinkedHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import graphql.execution.ExecutionContext;
import graphql.execution.instrumentation.InstrumentationContext;
import graphql.execution.instrumentation.InstrumentationState;
import graphql.execution.instrumentation.SimpleInstrumentation;
import graphql.execution.instrumentation.SimplePerformantInstrumentation;
import graphql.execution.instrumentation.parameters.InstrumentationExecuteOperationParameters;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
Expand All @@ -23,7 +23,7 @@
* exceeded. If the function returns {@code true} a {@link AbortExecutionException} is thrown.
*/
@PublicApi
public class MaxQueryDepthInstrumentation extends SimpleInstrumentation {
public class MaxQueryDepthInstrumentation extends SimplePerformantInstrumentation {

private static final Logger log = LoggerFactory.getLogger(MaxQueryDepthInstrumentation.class);

Expand Down
31 changes: 2 additions & 29 deletions src/main/java/graphql/collect/ImmutableKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,10 @@ public static <K, V> ImmutableMap<K, V> emptyMap() {
return ImmutableMap.of();
}

/**
* ImmutableMaps are hard to build via {@link Map#computeIfAbsent(Object, Function)} style. This method
* allows you to take a mutable map with mutable list of keys and make it immutable.
* <p>
* This of course has a cost - if the map is very large you will be using more memory. But for static
* maps that live a long life it maybe be worth it.
*
* @param startingMap the starting input map
* @param <K> for key
* @param <V> for victory
*
* @return and Immutable map of ImmutableList values
*/

public static <K, V> ImmutableMap<K, ImmutableList<V>> toImmutableMapOfLists(Map<K, List<V>> startingMap) {
assertNotNull(startingMap);
ImmutableMap.Builder<K, ImmutableList<V>> map = ImmutableMap.builder();
for (Map.Entry<K, List<V>> e : startingMap.entrySet()) {
ImmutableList<V> value = ImmutableList.copyOf(startingMap.getOrDefault(e.getKey(), emptyList()));
map.put(e.getKey(), value);
}
return map.build();
}


public static <K, V> ImmutableMap<K, V> addToMap(Map<K, V> existing, K newKey, V newVal) {
return ImmutableMap.<K, V>builder().putAll(existing).put(newKey, newVal).build();
}

public static <K, V> ImmutableMap<K, V> mergeMaps(Map<K, V> m1, Map<K, V> m2) {
return ImmutableMap.<K, V>builder().putAll(m1).putAll(m2).build();
}

public static <T> ImmutableList<T> concatLists(List<T> l1, List<T> l2) {
//noinspection UnstableApiUsage
return ImmutableList.<T>builderWithExpectedSize(l1.size() + l2.size()).addAll(l1).addAll(l2).build();
Expand Down Expand Up @@ -123,6 +94,7 @@ public static <T, R> ImmutableList<R> mapAndDropNulls(Iterable<? extends T> iter
*
* @return an Immutable list with the extra items.
*/
@SafeVarargs
public static <T> ImmutableList<T> addToList(Collection<? extends T> existing, T newValue, T... extraValues) {
assertNotNull(existing);
assertNotNull(newValue);
Expand All @@ -147,6 +119,7 @@ public static <T> ImmutableList<T> addToList(Collection<? extends T> existing, T
*
* @return an Immutable Set with the extra items.
*/
@SafeVarargs
public static <T> ImmutableSet<T> addToSet(Collection<? extends T> existing, T newValue, T... extraValues) {
assertNotNull(existing);
assertNotNull(newValue);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/graphql/execution/Execution.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ private CompletableFuture<ExecutionResult> executeOperation(ExecutionContext exe
}
result = executionStrategy.execute(executionContext, parameters);
} catch (NonNullableFieldWasNullException e) {
// this means it was non null types all the way from an offending non null type
// up to the root object type and there was a a null value some where.
// this means it was non-null types all the way from an offending non-null type
// up to the root object type and there was a null value somewhere.
//
// The spec says we should return null for the data in this case
//
// http://facebook.github.io/graphql/#sec-Errors-and-Non-Nullability
// https://spec.graphql.org/October2021/#sec-Handling-Field-Errors
//
result = completedFuture(new ExecutionResultImpl(null, executionContext.getErrors()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/graphql/execution/ExecutionContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public ValueUnboxer getValueUnboxer() {
public void addError(GraphQLError error, ResultPath fieldPath) {
synchronized (this) {
//
// see http://facebook.github.io/graphql/#sec-Errors-and-Non-Nullability about how per
// see https://spec.graphql.org/October2021/#sec-Handling-Field-Errors about how per
// field errors should be handled - ie only once per field if it's already there for nullability
// but unclear if it's not that error path
//
Expand Down
Loading