-
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.
- Loading branch information
Showing
12 changed files
with
648 additions
and
18 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
60 changes: 60 additions & 0 deletions
60
...allrye-graphql/src/main/java/io/quarkus/it/smallrye/graphql/metricresources/TestPojo.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,60 @@ | ||
package io.quarkus.it.smallrye.graphql.metricresources; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
/** | ||
* Just a test pojo | ||
*/ | ||
public class TestPojo { | ||
private String message; | ||
private List<String> list = Arrays.asList("a", "b", "c"); | ||
|
||
private Number number; | ||
|
||
public TestPojo() { | ||
super(); | ||
} | ||
|
||
public TestPojo(String message) { | ||
super(); | ||
this.message = message; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
|
||
public List<String> getList() { | ||
return list; | ||
} | ||
|
||
public void setList(List<String> list) { | ||
this.list = list; | ||
} | ||
|
||
public Number getNumber() { | ||
return number; | ||
} | ||
|
||
public void setNumber(Number number) { | ||
this.number = number; | ||
} | ||
|
||
// <placeholder> | ||
|
||
@Override | ||
public String toString() { | ||
return "TestPojo{" + "message=" + message + ", list=" + list + ", number=" + number + '}'; | ||
} | ||
|
||
enum Number { | ||
ONE, | ||
TWO, | ||
THREE | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...lrye-graphql/src/main/java/io/quarkus/it/smallrye/graphql/metricresources/TestRandom.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,31 @@ | ||
package io.quarkus.it.smallrye.graphql.metricresources; | ||
|
||
/** | ||
* Just a test pojo that contains a random number | ||
*/ | ||
public class TestRandom { | ||
private double value; | ||
|
||
public TestRandom() { | ||
this(Math.random()); | ||
} | ||
|
||
public TestRandom(double value) { | ||
super(); | ||
this.value = value; | ||
} | ||
|
||
public double getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(double value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "TestRandom{" + "value=" + value + '}'; | ||
} | ||
|
||
} |
138 changes: 138 additions & 0 deletions
138
...ye-graphql/src/main/java/io/quarkus/it/smallrye/graphql/metricresources/TestResource.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,138 @@ | ||
package io.quarkus.it.smallrye.graphql.metricresources; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.enterprise.event.Observes; | ||
import jakarta.inject.Inject; | ||
|
||
import org.eclipse.microprofile.graphql.GraphQLApi; | ||
import org.eclipse.microprofile.graphql.Mutation; | ||
import org.eclipse.microprofile.graphql.Query; | ||
import org.eclipse.microprofile.graphql.Source; | ||
|
||
import graphql.schema.GraphQLEnumType; | ||
import graphql.schema.GraphQLSchema; | ||
import io.micrometer.core.instrument.Metrics; | ||
import io.smallrye.graphql.api.Context; | ||
import io.smallrye.mutiny.Uni; | ||
import io.smallrye.mutiny.infrastructure.Infrastructure; | ||
|
||
/** | ||
* Just a test endpoint | ||
*/ | ||
@GraphQLApi | ||
public class TestResource { | ||
|
||
public static final double SLEEP_TIME = 0.15; | ||
@Inject | ||
Context context; | ||
|
||
@Query | ||
public TestPojo ping() { | ||
return new TestPojo("pong"); | ||
} | ||
|
||
@Query | ||
public TestPojo foo() { | ||
return new TestPojo("bar"); | ||
} | ||
|
||
@Query | ||
public TestPojo[] superMetricFoo() throws InterruptedException { | ||
Thread.sleep(sleepTimeInMilliseconds()); | ||
return new TestPojo[] { foo(), foo(), foo() }; | ||
} | ||
|
||
@Query | ||
public TestPojo[] foos() { | ||
return new TestPojo[] { foo() }; | ||
} | ||
|
||
@Query | ||
public List<TestPojo> batchFoo(@Source List<TestPojo> testPojos) throws InterruptedException { | ||
Thread.sleep(sleepTimeInMilliseconds()); | ||
return List.of(new TestPojo("bar1"), new TestPojo("bar2"), new TestPojo("bar3")); | ||
} | ||
|
||
@Query | ||
public Uni<List<TestPojo>> asyncBatchFoo(@Source List<TestPojo> testPojos) { | ||
return Uni.createFrom().item(() -> { | ||
try { | ||
Thread.sleep(sleepTimeInMilliseconds()); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
return List.of(new TestPojo("abar1"), new TestPojo("abar2"), new TestPojo("abar3")); | ||
}); | ||
} | ||
|
||
@Query("context") | ||
public String getPathFromContext() { | ||
return context.getPath(); | ||
} | ||
|
||
@Query | ||
public TestPojo systemserror() { | ||
throw new RuntimeException("Some system problem"); | ||
} | ||
|
||
@Mutation | ||
public TestPojo moo(String name) { | ||
return new TestPojo(name); | ||
} | ||
|
||
@Query | ||
public String testCharset(String characters) { | ||
return characters; | ||
} | ||
|
||
// <placeholder> | ||
@Query | ||
public Uni<TestPojo[]> asyncSuperMetricFoo() throws InterruptedException { | ||
return Uni.createFrom().item(() -> { | ||
try { | ||
Thread.sleep(sleepTimeInMilliseconds()); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
return new TestPojo[] { new TestPojo("async1"), new TestPojo("async2"), new TestPojo("async3") }; | ||
}).runSubscriptionOn(Infrastructure.getDefaultWorkerPool()); | ||
|
||
} | ||
|
||
@Mutation | ||
public void clearMetrics() { | ||
Metrics.globalRegistry.clear(); | ||
} | ||
|
||
public TestRandom getRandomNumber(@Source TestPojo testPojo) throws InterruptedException { | ||
Thread.sleep(sleepTimeInMilliseconds()); | ||
return new TestRandom(123); | ||
} | ||
|
||
public Uni<TestRandom> getRandomNumberAsync(@Source TestPojo testPojo) throws InterruptedException { | ||
return Uni.createFrom().item(() -> { | ||
try { | ||
Thread.sleep(sleepTimeInMilliseconds()); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
return new TestRandom(123); | ||
}); | ||
} | ||
|
||
public GraphQLSchema.Builder addMyOwnEnum(@Observes GraphQLSchema.Builder builder) { | ||
|
||
GraphQLEnumType myOwnEnum = GraphQLEnumType.newEnum() | ||
.name("SomeEnum") | ||
.description("Adding some enum type") | ||
.value("value1") | ||
.value("value2").build(); | ||
|
||
return builder.additionalType(myOwnEnum); | ||
} | ||
|
||
private long sleepTimeInMilliseconds() { | ||
return (long) (SLEEP_TIME * 1000); | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
integration-tests/smallrye-graphql/src/main/resources/application.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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
message=Production | ||
quarkus.smallrye-graphql.show-runtime-exception-message=org.eclipse.microprofile.faulttolerance.exceptions.TimeoutException | ||
quarkus.smallrye-graphql.show-runtime-exception-message=org.eclipse.microprofile.faulttolerance.exceptions.TimeoutException | ||
quarkus.smallrye-graphql.metrics.enabled=true |
Oops, something went wrong.