Skip to content

Commit

Permalink
Merge branch 'smallrye:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
t1 authored Apr 18, 2024
2 parents 13008e7 + ceb7554 commit 53bd1cc
Show file tree
Hide file tree
Showing 50 changed files with 595 additions and 93 deletions.
4 changes: 2 additions & 2 deletions .github/project.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: SmallRye GraphQL
release:
current-version: 2.8.1
next-version: 2.8.2-SNAPSHOT
current-version: 2.8.2
next-version: 2.8.3-SNAPSHOT
16 changes: 11 additions & 5 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
:subscriptions-transport-ws: https://github.com/apollographql/subscriptions-transport-ws
:graphql-ws: https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md
:graphql-federation: https://www.apollographql.com/docs/federation
:vertx: https://vertx.io/

image:https://github.com/smallrye/smallrye-graphql/workflows/SmallRye%20Build/badge.svg?branch=main[link=https://github.com/smallrye/smallrye-graphql/actions?query=workflow%3A%22SmallRye+Build%22]
image:https://sonarcloud.io/api/project_badges/measure?project=smallrye_smallrye-graphql&metric=alert_status["Quality Gate Status", link="https://sonarcloud.io/dashboard?id=smallrye_smallrye-graphql"]
Expand Down Expand Up @@ -62,17 +63,22 @@ The 1.5.x branch will be maintained for the `javax` namespace, and the main (2.x

* link:server/api[API] (pulling in the MicroProfile API) and allowing us to experiment with api feature not yet in the spec. Code from here might move the the spec at some point.
* link:server/implementation[Implementation] of the Eclipse MicroProfile GraphQL API.
* link:server/implementation-cdi[CDI] Module that allows lookup of GraphQL Endpoints via CDI
* link:server/implementation-servlet[Servlet] Making the implementation available via Servlet
* link:server/implementation-cdi[CDI] Module that allows lookup of GraphQL Endpoints via CDI.
* link:server/implementation-servlet[Servlet] Making the implementation available via Servlet.
* link:server/tck[TCK] Test suite to run the implementation against the {microprofile-graphql}[Eclipse MicroProfile GraphQL] TCK.
* link:server/runner[Runner] Manual TCK testing with GraphiQL
* link:server/integration-tests[IT] To run some Integration tests
* link:server/runner[Runner] Manual TCK testing with GraphiQL.
* link:server/integration-tests[IT] To run some Integration tests.

==== Client

* link:client/api[Client API] (pulling in the MicroProfile Client API) and allowing us to experiment with api feature not yet in the spec. Code from here might move the the spec at some point.
* link:client/api[Client API] (pulling in the MicroProfile Client API) and allowing us to experiment with API feature not yet in the spec. Code from here might move the spec at some point.
* link:client/implementation[Client Implementation] of the Eclipse MicroProfile GraphQL Client API.
* link:client/tck[Client TCK] Test suite to run the client-implementation against the {microprofile-graphql}[Eclipse MicroProfile GraphQL] Client TCK.
* link:client/implementation-vertx[Client Implementation Vert.x] Module for {vertx}[Vert.x] handling for the client.
* link:client/generator[Client Generator] Module generating Type-Safe Client APIs with annotation processing.
* link:client/generator-test[Client Generator Test] Module containing tests for client generators.
* link:client/model[Client Model] defines Type-Safe's client model (GraphQL operations).
* link:client/model-builder[Client Model Builder] that generates Client Model from Jandex.

==== Tools

Expand Down
2 changes: 1 addition & 1 deletion client/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-client-parent</artifactId>
<version>2.8.2-SNAPSHOT</version>
<version>2.8.3-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-client-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion client/generator-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-client-parent</artifactId>
<version>2.8.2-SNAPSHOT</version>
<version>2.8.3-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-client-generator-test</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion client/generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-client-parent</artifactId>
<version>2.8.2-SNAPSHOT</version>
<version>2.8.3-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-client-generator</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion client/implementation-vertx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-client-parent</artifactId>
<version>2.8.2-SNAPSHOT</version>
<version>2.8.3-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-client-implementation-vertx</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion client/implementation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-client-parent</artifactId>
<version>2.8.2-SNAPSHOT</version>
<version>2.8.3-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-client</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion client/model-builder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-client-parent</artifactId>
<version>2.8.2-SNAPSHOT</version>
<version>2.8.3-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-client-model-builder</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import static io.smallrye.graphql.client.model.Classes.OBJECT;
import static io.smallrye.graphql.client.model.Classes.OPTIONAL;
import static io.smallrye.graphql.client.model.Classes.TYPESAFE_RESPONSE;
import static io.smallrye.graphql.client.model.Classes.isParameterized;
import static io.smallrye.graphql.client.model.ScanningContext.getIndex;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;

import java.lang.reflect.Modifier;
Expand Down Expand Up @@ -384,7 +382,7 @@ public Stream<FieldModel> fields() {
* @return A stream of {@link FieldModel} instances.
*/
private Stream<FieldModel> fields(ClassInfo clazz) {
return (clazz == null) ? Stream.of()
return (clazz == null || clazz.superClassType() == null) ? Stream.of()
: Stream.concat(
fields(getIndex().getClassByName(clazz.superClassType().name())), // to superClass
fieldsHelper(clazz)
Expand Down
2 changes: 1 addition & 1 deletion client/model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-client-parent</artifactId>
<version>2.8.2-SNAPSHOT</version>
<version>2.8.3-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-client-model</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-parent</artifactId>
<version>2.8.2-SNAPSHOT</version>
<version>2.8.3-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-client-parent</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion client/tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-client-parent</artifactId>
<version>2.8.2-SNAPSHOT</version>
<version>2.8.3-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-client-tck</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-parent</artifactId>
<version>2.8.2-SNAPSHOT</version>
<version>2.8.3-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-common-parent</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion common/schema-builder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-common-parent</artifactId>
<version>2.8.2-SNAPSHOT</version>
<version>2.8.3-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-schema-builder</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ private Map<String, Operation> validateOperationNames(Map<String, Operation> ope
operations.keySet().forEach(fieldName -> {
if (type.getFields().keySet().contains(fieldName)) {
throw new SchemaBuilderException(String.format("Type '%s' already contains field named '%s'" +
" so source field, with the same name, cannot be applied", type.getName(), fieldName));
" so source field, with the same name, cannot be applied. You can resolve this conflict using @Ignore on the type's field.",
type.getName(),
fieldName));
}
});
return operations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ public void testSchemaWithSourceFieldNameDuplicates() {
} catch (SchemaBuilderException e) {
// ok
assertEquals("Type 'SomeClass' already contains field named 'password' so source field, " +
"with the same name, cannot be applied", e.getMessage());
"with the same name, cannot be applied. You can resolve this conflict using @Ignore on the type's field.",
e.getMessage());
}
}

Expand All @@ -165,7 +166,7 @@ public void testSchemaWithBatchSourceFieldNameDuplicates() {
} catch (SchemaBuilderException e) {
// ok
assertEquals(
"Type 'SomeClass' already contains field named 'password' so source field, with the same name, cannot be applied",
"Type 'SomeClass' already contains field named 'password' so source field, with the same name, cannot be applied. You can resolve this conflict using @Ignore on the type's field.",
e.getMessage());
}
}
Expand Down
2 changes: 1 addition & 1 deletion common/schema-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-common-parent</artifactId>
<version>2.8.2-SNAPSHOT</version>
<version>2.8.3-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-schema-model</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-parent</artifactId>
<version>2.8.2-SNAPSHOT</version>
<version>2.8.3-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-documentation</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-parent</artifactId>
<version>42</version>
<version>43</version>
</parent>

<artifactId>smallrye-graphql-parent</artifactId>
<version>2.8.2-SNAPSHOT</version>
<version>2.8.3-SNAPSHOT</version>

<packaging>pom</packaging>
<name>SmallRye: GraphQL Parent</name>
Expand Down
2 changes: 1 addition & 1 deletion release/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-parent</artifactId>
<version>2.8.2-SNAPSHOT</version>
<version>2.8.3-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-release</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion server/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-server-parent</artifactId>
<version>2.8.2-SNAPSHOT</version>
<version>2.8.3-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion server/implementation-cdi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-server-parent</artifactId>
<version>2.8.2-SNAPSHOT</version>
<version>2.8.3-SNAPSHOT</version>
</parent>

<artifactId>smallrye-graphql-cdi</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,6 @@ public Map<String, Object> getAddedExtensions() {
return SmallRyeContextManager.getCurrentSmallRyeContext().getAddedExtensions();
}

@Override
public void setAddedExtensions(Map<String, Object> addedExtensions) {
SmallRyeContextManager.getCurrentSmallRyeContext().setAddedExtensions(addedExtensions);
}

@Override
public void addExtension(String key, Object value) {
SmallRyeContextManager.getCurrentSmallRyeContext().addExtension(key, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import java.time.Duration;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;

import jakarta.enterprise.inject.spi.CDI;
import jakarta.enterprise.util.AnnotationLiteral;
Expand All @@ -13,6 +15,7 @@
import org.jboss.logging.Logger;

import io.smallrye.graphql.api.Context;
import io.smallrye.graphql.schema.model.OperationType;
import io.smallrye.graphql.spi.MetricsService;

/**
Expand All @@ -24,8 +27,10 @@
public class MPMetricsService implements MetricsService {

private MetricRegistry metricRegistry;
private final Map<Long, MetricMeasurement> metricsMemory = new ConcurrentHashMap<>();
private final Map<Long, MetricMeasurement<Long>> metricsMemory = new ConcurrentHashMap<>();
private final Map<String, AtomicLong> subscriptions = new ConcurrentHashMap<>();
private static final String METRIC_NAME = "mp_graphql";
private static final String METRIC_SUBSCRIPTIONS = "mp_graphql_subscription";
private Logger LOG = Logger.getLogger(MPMetricsService.class);

public MPMetricsService() {
Expand All @@ -41,7 +46,7 @@ private MetricRegistry getMetricRegistry() {
return metricRegistry;
}

private Tag[] getTags(MetricMeasurement metricMeasurement) {
private Tag[] getTags(MetricMeasurement<Long> metricMeasurement) {
return new Tag[] {
new Tag("name", metricMeasurement.getName()),
new Tag("type", metricMeasurement.getOperationType()),
Expand All @@ -51,7 +56,7 @@ private Tag[] getTags(MetricMeasurement metricMeasurement) {

@Override
public void start(Long measurementId, Context context) {
metricsMemory.put(measurementId, new MetricMeasurement(context.getFieldName(),
metricsMemory.put(measurementId, new MetricMeasurement<>(context.getFieldName(),
context.hasSource(),
context.getOperationType(),
System.nanoTime()));
Expand All @@ -60,13 +65,34 @@ public void start(Long measurementId, Context context) {

@Override
public void end(Long measurementId) {
MetricMeasurement metricMeasurement = metricsMemory.remove(measurementId);
long duration = System.nanoTime() - metricMeasurement.getTimeStarted();
MetricMeasurement<Long> metricMeasurement = metricsMemory.remove(measurementId);
long duration = System.nanoTime() - metricMeasurement.getMetric();
getMetricRegistry().simpleTimer(METRIC_NAME, getTags(metricMeasurement))
.update(Duration.ofNanos(duration));
LOG.tracef("(" + measurementId + ") Finished recording metrics for: %s", metricMeasurement.getName());
}

@Override
public void subscriptionStart(Context context) {
if (!OperationType.SUBSCRIPTION.name().equals(context.getOperationType())) {
return;
}
subscriptions.computeIfAbsent(context.getFieldName(), k -> new AtomicLong(0));
subscriptions.get(context.getFieldName()).incrementAndGet();
getMetricRegistry().gauge(
METRIC_SUBSCRIPTIONS,
() -> subscriptions.get(context.getFieldName()).get(),
new Tag("name", context.getFieldName()));
}

@Override
public void subscriptionEnd(Context context) {
if (!OperationType.SUBSCRIPTION.name().equals(context.getOperationType())) {
return;
}
Optional.ofNullable(subscriptions.get(context.getFieldName())).ifPresent(AtomicLong::decrementAndGet);
}

class VendorType extends AnnotationLiteral<RegistryType> implements RegistryType {
@Override
public MetricRegistry.Type type() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package io.smallrye.graphql.cdi.metrics;

public class MetricMeasurement {
public class MetricMeasurement<M> {
private String name;
private boolean source;
private String operationType;
private long timeStarted;
private M metric;

public MetricMeasurement(String name, boolean source, String operationType, long timeStarted) {
public MetricMeasurement(String name, boolean source, String operationType, M metric) {
this.name = name;
this.source = source;
this.operationType = operationType;
this.timeStarted = timeStarted;
this.metric = metric;
}

public String getName() {
Expand All @@ -25,7 +25,7 @@ public String getOperationType() {
return operationType;
}

public long getTimeStarted() {
return timeStarted;
public M getMetric() {
return metric;
}
}
Loading

0 comments on commit 53bd1cc

Please sign in to comment.