Skip to content

Commit

Permalink
ClientMutationId not populated properly
Browse files Browse the repository at this point in the history
  • Loading branch information
kaqqao committed Mar 21, 2021
1 parent 03420ff commit 4f712e6
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package io.leangen.graphql.spqr.spring.autoconfigure;

import graphql.GraphQL;
import graphql.execution.instrumentation.Instrumentation;
import graphql.schema.GraphQLSchema;
import io.leangen.geantyref.GenericTypeReflector;
import io.leangen.graphql.ExtendedGeneratorConfiguration;
import io.leangen.graphql.ExtensionProvider;
import io.leangen.graphql.GeneratorConfiguration;
import io.leangen.graphql.GraphQLRuntime;
import io.leangen.graphql.GraphQLSchemaGenerator;
import io.leangen.graphql.execution.ResolverInterceptorFactory;
import io.leangen.graphql.generator.mapping.ArgumentInjector;
Expand Down Expand Up @@ -269,8 +271,12 @@ public GraphQLSchema graphQLSchema(GraphQLSchemaGenerator schemaGenerator) {

@Bean
@ConditionalOnMissingBean
public GraphQL graphQL(GraphQLSchema schema) {
GraphQL.Builder builder = GraphQL.newGraphQL(schema);
public GraphQL graphQL(GraphQLSchema schema, SpqrProperties spqrProperties, List<Instrumentation> instrumentations) {
GraphQLRuntime.Builder builder = GraphQLRuntime.newGraphQL(schema);
instrumentations.forEach(builder::instrumentation);
if (spqrProperties.getMaxComplexity() > 1) {
builder.maximumQueryComplexity(spqrProperties.getMaxComplexity());
}
return builder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public class DefaultGlobalContext<R> {

private final R nativeRequest;
private final Map<String, Object> extensions;
private final Map<Object, Object> extensions;

public DefaultGlobalContext(R request) {
this.nativeRequest = request;
Expand All @@ -18,12 +18,12 @@ public R getNativeRequest() {
}

@SuppressWarnings("unchecked")
public <T> T getExtension(String key) {
public <T> T getExtension(Object key) {
return (T) extensions.get(key);
}

@SuppressWarnings("unchecked")
public <T> T setExtension(String key, T value) {
public <T> T setExtension(Object key, T value) {
return (T) extensions.put(key, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class SpqrProperties {
// Core properties
private String[] basePackages;
private boolean abstractInputTypeResolution;
private int maxComplexity = -1;
private Relay relay = new Relay();

// Web properties
Expand Down Expand Up @@ -56,6 +57,14 @@ public void setAbstractInputTypeResolution(boolean abstractInputTypeResolution)
this.abstractInputTypeResolution = abstractInputTypeResolution;
}

public int getMaxComplexity() {
return maxComplexity;
}

public void setMaxComplexity(int maxComplexity) {
this.maxComplexity = maxComplexity;
}

public Relay getRelay() {
return relay;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import io.leangen.graphql.execution.InvocationContext;
import io.leangen.graphql.execution.ResolverInterceptor;
import io.leangen.graphql.spqr.spring.web.reactive.WebFluxContext;
import io.leangen.graphql.util.ContextUtils;
import reactor.core.publisher.Flux;

public class FluxInterceptor implements ResolverInterceptor {

@Override
public Object aroundInvoke(InvocationContext context, Continuation continuation) throws Exception {
WebFluxContext reactiveContext = (WebFluxContext) context.getResolutionEnvironment().rootContext;
WebFluxContext reactiveContext = (WebFluxContext) ContextUtils.unwrapContext(context.getResolutionEnvironment().rootContext);
return ((Flux<?>) continuation.proceed(context)).contextWrite(reactiveContext.getSubscriberContext());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import io.leangen.graphql.execution.InvocationContext;
import io.leangen.graphql.execution.ResolverInterceptor;
import io.leangen.graphql.spqr.spring.web.reactive.WebFluxContext;
import io.leangen.graphql.util.ContextUtils;
import reactor.core.publisher.Mono;

public class MonoInterceptor implements ResolverInterceptor {

@Override
public Object aroundInvoke(InvocationContext context, Continuation continuation) throws Exception {
WebFluxContext reactiveContext = (WebFluxContext) context.getResolutionEnvironment().rootContext;
WebFluxContext reactiveContext = (WebFluxContext) ContextUtils.unwrapContext(context.getResolutionEnvironment().rootContext);
return ((Mono<?>) continuation.proceed(context)).contextWrite(reactiveContext.getSubscriberContext());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.net.URI;

import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

@RunWith(SpringRunner.class)
@WebFluxTest
Expand Down

0 comments on commit 4f712e6

Please sign in to comment.