How can I get the String from the query ? #1373
Replies: 4 comments
-
Hello, what i would ask is what are you trying to achieve ? if you really need to access to the original query string you can use Instrumentation and the various hooks that it provides: from those hooks you can access to the |
Beta Was this translation helpful? Give feedback.
-
Hello, so I would like to get the String of the query directly from the DataFetchingEnvironment, is there any way to do this? something like: @Component
class ProfileQuery(private val profileDao: ProfileDao) : Query {
fun profile(env: DataFetchingEnvironment): List<Profile> {
val b = env.getContext.graphqlQuery
return listOf()
}
} Can I get this value from ServerRequest, for example? |
Beta Was this translation helpful? Give feedback.
-
in theory at this layer of the execution you should be agnostic of an http request because you are executing a graphQL operation. unfortunately there is no way to access to the query because at the dataFetcher layer the raw query its not needed. more info here you could try to use the AST Document which is available in the DataFetchingEnvironment but again, i would verify what are you trying to achieve, and if is needed rely on the instrumentation hooks. (those actually provide the query string) |
Beta Was this translation helpful? Give feedback.
-
You could store raw query in your |
Beta Was this translation helpful? Give feedback.
-
Hi, first I would like to thank you for the repository
I have a code similar to this, I'm using spring boot with kotlin and the graphql kotlin spring server library:
I would like to know how I can retrieve the String value from the graphql query, for example:
query {
profile {
id
name
}
}
Beta Was this translation helpful? Give feedback.
All reactions