question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

queries using GraphQLContext fail with "argument type mismatch"

See original GitHub issue

Library Version 4.0.0-alpha.17

Describe the bug Any request using GraphQLContext fails with Exception while fetching data (/functionWithContext) : argument type mismatch

@Component
class HealthCheck: Query {
    fun isAlive() = true

    fun isAliveWithContext(graphQLAuthContext: GraphQLAuthContext) = true
}
@Component
class ContextFactory : GraphQLContextFactory<GraphQLAuthContext, ServerHttpRequest> {
    override suspend fun generateContext(request: ServerHttpRequest): GraphQLAuthContext? {
        return GraphQLAuthContext(isVerified = true)
    }
}

data class GraphQLAuthContext(val isVerified: Boolean) : GraphQLContext

This works fine when testing with the playground (as expected)

{
  isAlive
}

This fails regardless of headers, it never enters the ContextFactory either.

{
  isAliveWithContext
}

Response:

{
  "errors": [
    {
      "message": "Exception while fetching data (/isAliveWithContext) : argument type mismatch",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "isAliveWithContext"
      ]
    }
  ]
}

Expected behaviour Both requests succeed fine

Notes This started occurring when bumping from alpha10 to alpha17 with no similar issues prior. the same behaviour occurs with alpha16 (I didn’t test further due to the package changes being a hassle to change across my whole project)

Stack Trace

08:45:00.490 | reactor-http-epoll-2 @coroutine#12 | WARN  | notprivacysafe.graphql.execution.SimpleDataFetcherExceptionHandler | Exception while fetching data (/isAliveWithContext) : argument type mismatch
java.lang.IllegalArgumentException: argument type mismatch
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?]
	at kotlin.reflect.jvm.internal.calls.CallerImpl$Method.callMethod(CallerImpl.kt:97) ~[kotlin-reflect-1.4.31.jar:1.4.31-release-344 (1.4.31)]
	at kotlin.reflect.jvm.internal.calls.CallerImpl$Method$Instance.call(CallerImpl.kt:113) ~[kotlin-reflect-1.4.31.jar:1.4.31-release-344 (1.4.31)]
	at kotlin.reflect.jvm.internal.KCallableImpl.call(KCallableImpl.kt:108) ~[kotlin-reflect-1.4.31.jar:1.4.31-release-344 (1.4.31)]
	at kotlin.reflect.jvm.internal.KCallableImpl.callDefaultMethod$kotlin_reflection(KCallableImpl.kt:159) ~[kotlin-reflect-1.4.31.jar:1.4.31-release-344 (1.4.31)]
	at kotlin.reflect.jvm.internal.KCallableImpl.callBy(KCallableImpl.kt:112) ~[kotlin-reflect-1.4.31.jar:1.4.31-release-344 (1.4.31)]
	at com.expediagroup.graphql.generator.execution.FunctionDataFetcher.runBlockingFunction(FunctionDataFetcher.kt:173) ~[graphql-kotlin-schema-generator-4.0.0-alpha.17.jar:4.0.0-alpha.17]
	at com.expediagroup.graphql.generator.execution.FunctionDataFetcher.get(FunctionDataFetcher.kt:72) ~[graphql-kotlin-schema-generator-4.0.0-alpha.17.jar:4.0.0-alpha.17]
	at graphql.execution.ExecutionStrategy.fetchField(ExecutionStrategy.java:270) [graphql-java-16.2.jar:?]
	at graphql.execution.ExecutionStrategy.resolveFieldWithInfo(ExecutionStrategy.java:203) [graphql-java-16.2.jar:?]
	at graphql.execution.AsyncExecutionStrategy.execute(AsyncExecutionStrategy.java:60) [graphql-java-16.2.jar:?]
	at graphql.execution.Execution.executeOperation(Execution.java:165) [graphql-java-16.2.jar:?]
	at graphql.execution.Execution.execute(Execution.java:104) [graphql-java-16.2.jar:?]
	at graphql.GraphQL.execute(GraphQL.java:557) [graphql-java-16.2.jar:?]
	at graphql.GraphQL.parseValidateAndExecute(GraphQL.java:482) [graphql-java-16.2.jar:?]
	at graphql.GraphQL.executeAsync(GraphQL.java:446) [graphql-java-16.2.jar:?]
	at com.expediagroup.graphql.server.execution.GraphQLRequestHandler.executeRequest$suspendImpl(GraphQLRequestHandler.kt:45) [graphql-kotlin-server-4.0.0-alpha.17.jar:4.0.0-alpha.17]
	at com.expediagroup.graphql.server.execution.GraphQLRequestHandler.executeRequest(GraphQLRequestHandler.kt) [graphql-kotlin-server-4.0.0-alpha.17.jar:4.0.0-alpha.17]
	at com.expediagroup.graphql.server.execution.GraphQLServer.execute$suspendImpl(GraphQLServer.kt:48) [graphql-kotlin-server-4.0.0-alpha.17.jar:4.0.0-alpha.17]
	at com.expediagroup.graphql.server.execution.GraphQLServer$execute$1.invokeSuspend(GraphQLServer.kt) [graphql-kotlin-server-4.0.0-alpha.17.jar:4.0.0-alpha.17]
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) [kotlin-stdlib-1.4.31.jar:1.4.31-release-344 (1.4.31)]
	at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:234) [kotlinx-coroutines-core-jvm-1.4.3.jar:?]
	at kotlinx.coroutines.DispatchedTaskKt.resumeUnconfined(DispatchedTask.kt:190) [kotlinx-coroutines-core-jvm-1.4.3.jar:?]
	at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:161) [kotlinx-coroutines-core-jvm-1.4.3.jar:?]
	at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:369) [kotlinx-coroutines-core-jvm-1.4.3.jar:?]
	at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:403) [kotlinx-coroutines-core-jvm-1.4.3.jar:?]
	at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:395) [kotlinx-coroutines-core-jvm-1.4.3.jar:?]
	at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:300) [kotlinx-coroutines-core-jvm-1.4.3.jar:?]
	at kotlinx.coroutines.reactive.AwaitKt$awaitOne$$inlined$suspendCancellableCoroutine$lambda$1.onNext(Await.kt:114) [kotlinx-coroutines-reactive-1.3.8.jar:?]
	at reactor.core.publisher.StrictSubscriber.onNext(StrictSubscriber.java:89) [reactor-core-3.3.10.RELEASE.jar:3.3.10.RELEASE]
	at reactor.core.publisher.FluxContextStart$ContextStartSubscriber.onNext(FluxContextStart.java:96) [reactor-core-3.3.10.RELEASE.jar:3.3.10.RELEASE]
	at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:73) [reactor-core-3.3.10.RELEASE.jar:3.3.10.RELEASE]
	at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:73) [reactor-core-3.3.10.RELEASE.jar:3.3.10.RELEASE]
	at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1782) [reactor-core-3.3.10.RELEASE.jar:3.3.10.RELEASE]
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:144) [reactor-core-3.3.10.RELEASE.jar:3.3.10.RELEASE]
	at reactor.core.publisher.FluxContextStart$ContextStartSubscriber.onNext(FluxContextStart.java:96) [reactor-core-3.3.10.RELEASE.jar:3.3.10.RELEASE]
	at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:287) [reactor-core-3.3.10.RELEASE.jar:3.3.10.RELEASE]
	at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onNext(FluxFilterFuseable.java:330) [reactor-core-3.3.10.RELEASE.jar:3.3.10.RELEASE]
	at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1782) [reactor-core-3.3.10.RELEASE.jar:3.3.10.RELEASE]
	at reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:152) [reactor-core-3.3.10.RELEASE.jar:3.3.10.RELEASE]
	at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:136) [reactor-core-3.3.10.RELEASE.jar:3.3.10.RELEASE]
	at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:252) [reactor-core-3.3.10.RELEASE.jar:3.3.10.RELEASE]
	at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:136) [reactor-core-3.3.10.RELEASE.jar:3.3.10.RELEASE]
	at reactor.netty.channel.FluxReceive.onInboundComplete(FluxReceive.java:374) [reactor-netty-0.9.12.RELEASE.jar:0.9.12.RELEASE]
	at reactor.netty.channel.ChannelOperations.onInboundComplete(ChannelOperations.java:373) [reactor-netty-0.9.12.RELEASE.jar:0.9.12.RELEASE]
	at reactor.netty.http.server.HttpServerOperations.onInboundNext(HttpServerOperations.java:492) [reactor-netty-0.9.12.RELEASE.jar:0.9.12.RELEASE]
	at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:96) [reactor-netty-0.9.12.RELEASE.jar:0.9.12.RELEASE]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.52.Final.jar:4.1.52.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.52.Final.jar:4.1.52.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.52.Final.jar:4.1.52.Final]
	at reactor.netty.http.server.HttpTrafficHandler.channelRead(HttpTrafficHandler.java:216) [reactor-netty-0.9.12.RELEASE.jar:0.9.12.RELEASE]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.52.Final.jar:4.1.52.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.52.Final.jar:4.1.52.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.52.Final.jar:4.1.52.Final]
	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) [netty-transport-4.1.52.Final.jar:4.1.52.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324) [netty-codec-4.1.52.Final.jar:4.1.52.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296) [netty-codec-4.1.52.Final.jar:4.1.52.Final]
	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) [netty-transport-4.1.52.Final.jar:4.1.52.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.52.Final.jar:4.1.52.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.52.Final.jar:4.1.52.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.52.Final.jar:4.1.52.Final]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) [netty-transport-4.1.52.Final.jar:4.1.52.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.52.Final.jar:4.1.52.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.52.Final.jar:4.1.52.Final]
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) [netty-transport-4.1.52.Final.jar:4.1.52.Final]
	at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795) [netty-transport-native-epoll-4.1.52.Final-linux-x86_64.jar:4.1.52.Final]
	at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:475) [netty-transport-native-epoll-4.1.52.Final-linux-x86_64.jar:4.1.52.Final]
	at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378) [netty-transport-native-epoll-4.1.52.Final-linux-x86_64.jar:4.1.52.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) [netty-common-4.1.52.Final.jar:4.1.52.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-common-4.1.52.Final.jar:4.1.52.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.52.Final.jar:4.1.52.Final]
	at java.lang.Thread.run(Thread.java:832) [?:?]

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
MarcusDunncommented, Mar 29, 2021

Well, not to say I’m particularly surprised the issue was on my end. The issue was using GraphQLContext instead of SpringGraphQLContext in addition to SpringGraphQLContextFactory and its non-spring counterpart. Hopefully, registering the issue helps someone else and wasn’t just an exercise in wasting your time. Very appreciative of how active and well maintained this repo is, thanks for all the work!

1reaction
smyrickcommented, Mar 27, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Graphql context not set when graphql path has variables #452
There will be an error thrown : Exception while fetching data (getProjects) : argument type mismatch. Expected behavior. The graphql context ...
Read more >
Argument of type 'ApolloServer' is not assignable to parameter ...
I've updated to apollo-server-express and apollo-server-testing to 2.9.16. Then, this type error has disappeared. Please try it.
Read more >
GraphQL - Quick Guide - Tutorialspoint
GraphQL is strongly typed and the queries are based on fields and their associated data types. If there is type mismatch in a...
Read more >
express-graphql : context is always undefined - You.com
I'm building an app which is using Node/Express and Graphql. We are using this module for graphql-server-express and also we are using express-session...
Read more >
leangen/graphql-spqr - Gitter
See if the stack trace helps in figuring out where the mismatch originated. ... a way in graphql-spqr where we can return both...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found