Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract query name and it's fields from a GraphQL query in java

I'm basically trying to instrument GraphQL queries to identify what queries and fields the user is hitting the most. For this I want to extract the query name and it's respective fields whenever the point graphQL.execute(query) hits in my code.

I've seen some posts that were using/suggesting to use Apollo server but I do not use Apollo. For example in this query

query getMultipleResults {
  personSearch(text: "xyz") {
   totalCount
   results {
     name
     dob
     SSN
   }
  }
 }

I would like to get the query name: personSearch and the fields to be: totalCount, results and its fields name, dob and SSN.

like image 904
pj0129 Avatar asked Jun 24 '26 21:06

pj0129


1 Answers

While creating the graphql schema, you can define the instrumentation type. While every graphql execution, get the execution result which has the tracing information in details about fields ,time and resolver. for more information please refer my GitHub account : AnkushNakaskar with project "springbootspqrgraphql" For tracing : please add "TracingInstrumentation" for tracing.

like image 85
Ankush Nakaskar Avatar answered Jun 30 '26 17:06

Ankush Nakaskar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!