Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QSERVER-17812-Introspection_disabled true #255

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import graphql.schema.idl.SchemaParser;
import graphql.schema.idl.TypeDefinitionRegistry;
import graphql.schema.idl.TypeRuntimeWiring;
import graphql.schema.visibility.NoIntrospectionGraphqlFieldVisibility;
import lombok.SneakyThrows;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -68,7 +69,7 @@ public TypeDefinitionRegistry graphqlRegistry(@Value("classpath:schema.graphql")
@Bean
@ConditionalOnMissingBean
public RuntimeWiring graphqlWiring(Gom gom, Collection<Scalar<?, ?, ?>> scalars, Collection<TypeRuntimeWiring> wirings) {
var wiring = RuntimeWiring.newRuntimeWiring();
var wiring = RuntimeWiring.newRuntimeWiring().fieldVisibility(NoIntrospectionGraphqlFieldVisibility.NO_INTROSPECTION_FIELD_VISIBILITY);
scalars.stream().map(Scalar::build).forEach(wiring::scalar);
wirings.forEach(wiring::type);
gom.decorateRuntimeWiringBuilder(wiring);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
import com.qudini.reactive.logging.Log;
import graphql.ExecutionResult;
import graphql.GraphQL;
import graphql.analysis.MaxQueryComplexityInstrumentation;
import graphql.analysis.MaxQueryDepthInstrumentation;
import graphql.execution.DataFetcherExceptionHandler;
import graphql.execution.instrumentation.ChainedInstrumentation;
import graphql.execution.instrumentation.Instrumentation;
import graphql.schema.GraphQLSchema;
import lombok.RequiredArgsConstructor;
import org.dataloader.DataLoaderRegistry;
Expand All @@ -16,6 +19,7 @@
import reactor.core.publisher.Mono;
import reactor.util.context.ContextView;

import java.util.Arrays;
import java.util.Map;

import static com.qudini.utils.MoreTuples.onBoth;
Expand Down Expand Up @@ -46,18 +50,28 @@ private Mono<Map<String, Object>> execute(ContextView context, GraphQLRequest re
var input = request.toExecutionInput(context, registry);
var graphql = GraphQL
.newGraphQL(schema)
.instrumentation(new MaxQueryDepthInstrumentation(maxDepth))
.instrumentation(instrumentation())
.defaultDataFetcherExceptionHandler(exceptionHandler)
.build();
return Log
.thenFuture(() -> graphql.executeAsync(input))
.map(ExecutionResult::toSpecification);
}


private Mono<ServerResponse> respond(Mono<Map<String, Object>> body) {
return ok()
.contentType(APPLICATION_JSON)
.body(body, ParameterizedTypeReference.forType(Map.class));
}

public Instrumentation instrumentation() {
return new ChainedInstrumentation(
Arrays.asList(
new MaxQueryDepthInstrumentation(maxDepth), // Limit query depth to maxDepth
new MaxQueryComplexityInstrumentation(maxDepth) // Limit query complexity to maxDepth
)
);
}

}