-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 #25194 from phillip-kruger/gql-nb
GraphQL Non blocking support
- Loading branch information
Showing
32 changed files
with
1,785 additions
and
89 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
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
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
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
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
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
83 changes: 83 additions & 0 deletions
83
...ye-graphql/deployment/src/test/java/io/quarkus/smallrye/graphql/deployment/ErrorTest.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,83 @@ | ||
package io.quarkus.smallrye.graphql.deployment; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
import org.eclipse.microprofile.graphql.GraphQLApi; | ||
import org.eclipse.microprofile.graphql.Query; | ||
import org.jboss.shrinkwrap.api.asset.EmptyAsset; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
import io.smallrye.common.annotation.NonBlocking; | ||
|
||
public class ErrorTest extends AbstractGraphQLTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(ErrorApi.class, Foo.class) | ||
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")); | ||
|
||
@Test | ||
public void testNonBlockingError() { | ||
String query = getPayload("{ foo { message} }"); | ||
RestAssured.given() | ||
.body(query) | ||
.contentType(MEDIATYPE_JSON) | ||
.post("/graphql/") | ||
.then() | ||
.assertThat() | ||
.statusCode(500); | ||
} | ||
|
||
@Test | ||
public void testBlockingError() { | ||
String query = getPayload("{ blockingFoo { message} }"); | ||
RestAssured.given() | ||
.body(query) | ||
.contentType(MEDIATYPE_JSON) | ||
.post("/graphql/") | ||
.then() | ||
.log().everything() | ||
.assertThat() | ||
.statusCode(500); | ||
} | ||
|
||
public static class Foo { | ||
|
||
private String message; | ||
|
||
public Foo(String foo) { | ||
this.message = foo; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
|
||
} | ||
|
||
@GraphQLApi | ||
@ApplicationScoped | ||
public static class ErrorApi { | ||
|
||
@Query | ||
@NonBlocking | ||
public Foo foo() { | ||
throw new OutOfMemoryError("a SuperHero has used all the memory"); | ||
} | ||
|
||
@Query | ||
public Foo blockingFoo() { | ||
throw new OutOfMemoryError("a SuperHero has used all the memory"); | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.