pj0129
pj0129

Reputation: 75

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.

Upvotes: 3

Views: 1242

Answers (1)

Ankush Nakaskar
Ankush Nakaskar

Reputation: 131

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.

Upvotes: 1

Related Questions