-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from bclozel/graphql-java
Add support for GraphQL Java 19.2
- Loading branch information
Showing
19 changed files
with
394 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[ | ||
"reflect-config.json", | ||
"resource-config.json" | ||
] |
44 changes: 44 additions & 0 deletions
44
metadata/com.graphql-java/graphql-java/19.2/reflect-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
[ | ||
{ | ||
"name": "graphql.schema.GraphQLArgument", | ||
"allPublicMethods": true, | ||
"condition": { | ||
"typeReachable": "graphql.GraphQL" | ||
} | ||
}, | ||
{ | ||
"name": "graphql.schema.GraphQLDirective", | ||
"allPublicMethods": true, | ||
"condition": { | ||
"typeReachable": "graphql.GraphQL" | ||
} | ||
}, | ||
{ | ||
"name": "graphql.schema.GraphQLEnumValueDefinition", | ||
"allPublicMethods": true, | ||
"condition": { | ||
"typeReachable": "graphql.GraphQL" | ||
} | ||
}, | ||
{ | ||
"name": "graphql.schema.GraphQLFieldDefinition", | ||
"allPublicMethods": true, | ||
"condition": { | ||
"typeReachable": "graphql.GraphQL" | ||
} | ||
}, | ||
{ | ||
"name": "graphql.schema.GraphQLInputObjectField", | ||
"allPublicMethods": true, | ||
"condition": { | ||
"typeReachable": "graphql.GraphQL" | ||
} | ||
}, | ||
{ | ||
"name": "graphql.schema.GraphQLOutputType", | ||
"allPublicMethods": true, | ||
"condition": { | ||
"typeReachable": "graphql.GraphQL" | ||
} | ||
} | ||
] |
19 changes: 19 additions & 0 deletions
19
metadata/com.graphql-java/graphql-java/19.2/resource-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"bundles": [ | ||
{ | ||
"name": "i18n.General" | ||
}, | ||
{ | ||
"name": "i18n.Parsing" | ||
}, | ||
{ | ||
"name": "i18n.Scalars" | ||
}, | ||
{ | ||
"name": "i18n.Validation" | ||
} | ||
], | ||
"resources": { | ||
"includes": [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[ | ||
{ | ||
"latest": true, | ||
"metadata-version": "19.2", | ||
"module": "com.graphql-java:graphql-java", | ||
"tested-versions": [ | ||
"19.2" | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
gradlew.bat | ||
gradlew | ||
gradle/ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
|
||
import org.graalvm.internal.tck.TestUtils | ||
|
||
plugins { | ||
id "org.graalvm.internal.tck" | ||
} | ||
|
||
String libraryVersion = TestUtils.testedLibraryVersion | ||
|
||
dependencies { | ||
testImplementation "com.graphql-java:graphql-java:$libraryVersion" | ||
testImplementation 'org.assertj:assertj-core:3.22.0' | ||
testImplementation 'org.awaitility:awaitility:4.2.0' | ||
} |
2 changes: 2 additions & 0 deletions
2
tests/src/com.graphql-java/graphql-java/19.2/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
library.version = 19.2 | ||
metadata.dir = com.graphql-java/graphql-java/19.2/ |
13 changes: 13 additions & 0 deletions
13
tests/src/com.graphql-java/graphql-java/19.2/settings.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
pluginManagement { | ||
def tckPath = Objects.requireNonNullElse( | ||
System.getenv("GVM_TCK_TCKDIR"), | ||
"../../../../tck-build-logic" | ||
) | ||
includeBuild(tckPath) | ||
} | ||
|
||
plugins { | ||
id "org.graalvm.internal.tck-settings" version "1.0.0-SNAPSHOT" | ||
} | ||
|
||
rootProject.name = 'graphql-java-tests' |
77 changes: 77 additions & 0 deletions
77
tests/src/com.graphql-java/graphql-java/19.2/src/test/java/graphql/GraphQlTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
package graphql; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.function.Consumer; | ||
|
||
import graphql.introspection.IntrospectionQuery; | ||
import graphql.schema.GraphQLSchema; | ||
import graphql.schema.StaticDataFetcher; | ||
import graphql.schema.TypeResolver; | ||
import graphql.schema.idl.RuntimeWiring; | ||
import graphql.schema.idl.SchemaGenerator; | ||
import graphql.schema.idl.SchemaParser; | ||
import graphql.schema.idl.TypeDefinitionRegistry; | ||
import graphql.starwars.Droid; | ||
import graphql.starwars.Human; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* @author Brian Clozel | ||
*/ | ||
public class GraphQlTests { | ||
|
||
|
||
@Test | ||
void greetingQuery() throws Exception { | ||
GraphQLSchema graphQLSchema = parseSchema("greeting", runtimeWiringBuilder -> | ||
runtimeWiringBuilder.type("Query", builder -> | ||
builder.dataFetcher("greeting", new StaticDataFetcher("Hello GraphQL")))); | ||
GraphQL graphQl = GraphQL.newGraphQL(graphQLSchema).build(); | ||
ExecutionResult result = graphQl.execute("{ greeting }"); | ||
assertThat(result.getErrors()).isEmpty(); | ||
assertThat(result.getData().toString()).isEqualTo("{greeting=Hello GraphQL}"); | ||
} | ||
|
||
@Test | ||
void introspectionQuery() throws Exception { | ||
GraphQLSchema graphQLSchema = parseSchema("starwars", runtimeWiringBuilder -> { | ||
runtimeWiringBuilder.type("Query", builder -> builder.typeName("Character").typeResolver(characterTypeResolver())); | ||
}); | ||
GraphQL graphQl = GraphQL.newGraphQL(graphQLSchema).build(); | ||
ExecutionResult result = graphQl.execute(IntrospectionQuery.INTROSPECTION_QUERY); | ||
assertThat(result.getErrors()).isEmpty(); | ||
assertThat(result.getData().toString()).contains("{__schema={queryType={name=QueryType}"); | ||
} | ||
|
||
private GraphQLSchema parseSchema(String schemaFileName, Consumer<RuntimeWiring.Builder> consumer) throws IOException { | ||
try (InputStream inputStream = GraphQlTests.class.getResourceAsStream(schemaFileName + ".graphqls")) { | ||
TypeDefinitionRegistry registry = new SchemaParser().parse(inputStream); | ||
RuntimeWiring.Builder runtimeWiringBuilder = RuntimeWiring.newRuntimeWiring(); | ||
consumer.accept(runtimeWiringBuilder); | ||
return new SchemaGenerator().makeExecutableSchema(registry, runtimeWiringBuilder.build()); | ||
} | ||
} | ||
|
||
private TypeResolver characterTypeResolver() { | ||
return env -> { | ||
Object javaObject = env.getObject(); | ||
if (javaObject instanceof Droid) { | ||
return env.getSchema().getObjectType("Droid"); | ||
} else if (javaObject instanceof Human) { | ||
return env.getSchema().getObjectType("Human"); | ||
} else { | ||
throw new IllegalStateException("Unknown Character type"); | ||
} | ||
}; | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
tests/src/com.graphql-java/graphql-java/19.2/src/test/java/graphql/starwars/Character.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
package graphql.starwars; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author Brian Clozel | ||
*/ | ||
public interface Character { | ||
|
||
Long getId(); | ||
|
||
String getName(); | ||
|
||
Character getFriends(); | ||
|
||
List<Episode> getAppearsIn(); | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
tests/src/com.graphql-java/graphql-java/19.2/src/test/java/graphql/starwars/Droid.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
package graphql.starwars; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author Brian Clozel | ||
*/ | ||
public class Droid implements Character { | ||
|
||
@Override | ||
public Long getId() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Character getFriends() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public List<Episode> getAppearsIn() { | ||
return null; | ||
} | ||
|
||
public String getPrimaryFunction() { | ||
return null; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
tests/src/com.graphql-java/graphql-java/19.2/src/test/java/graphql/starwars/Episode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
package graphql.starwars; | ||
|
||
/** | ||
* @author Brian Clozel | ||
*/ | ||
public enum Episode { | ||
NEWHOPE, | ||
EMPIRE, | ||
JEDI | ||
} |
39 changes: 39 additions & 0 deletions
39
tests/src/com.graphql-java/graphql-java/19.2/src/test/java/graphql/starwars/Human.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright and related rights waived via CC0 | ||
* | ||
* You should have received a copy of the CC0 legalcode along with this | ||
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
*/ | ||
package graphql.starwars; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author Brian Clozel | ||
*/ | ||
public class Human implements Character { | ||
|
||
@Override | ||
public Long getId() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Character getFriends() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public List<Episode> getAppearsIn() { | ||
return null; | ||
} | ||
|
||
public String getHomePlanet() { | ||
return null; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...a/19.2/src/test/resources/META-INF/native-image/graphql-test-metadata/reflect-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
19 changes: 19 additions & 0 deletions
19
.../19.2/src/test/resources/META-INF/native-image/graphql-test-metadata/resource-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"bundles": [], | ||
"resources": { | ||
"includes": [ | ||
{ | ||
"pattern": "\\Qgraphql/greeting.graphqls\\E", | ||
"condition": { | ||
"typeReachable": "graphql.GraphQL" | ||
} | ||
}, | ||
{ | ||
"pattern": "\\Qgraphql/starwars.graphqls\\E", | ||
"condition": { | ||
"typeReachable": "graphql.GraphQL" | ||
} | ||
} | ||
] | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
tests/src/com.graphql-java/graphql-java/19.2/src/test/resources/graphql/greeting.graphqls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
type Query { | ||
greeting: String | ||
} |
Oops, something went wrong.