How to get original GraphQL query from AWS AppSync request

292 views Asked by At

Introduction

Currently, we're using AWS AppSync as API entry point for our proper GraphQL API.

The point is that we need to retrieve the original GraphQL query from the request AppSync sends to our GraphQL API.

In brief we have:

Client --[original query]--> AppSync (build its own request from client query) --[modified request]--> GraphQL API

Where we are missing the original query to the GraphQL API.

Comparison with documentation

Here the documentation of AWS AppSync mapping: https://docs.aws.amazon.com/appsync/latest/devguide/resolver-context-reference.html#aws-appsync-resolver-context-reference-info.

The field context.info.selectionSetGraphQL should be our solution but we don't receive the same content as the documentation ; in documentation, it seems to store the whole original query, however in practice we only get selected fields, not the complete query.

Attempts

We tried to rebuild the original query string from AWS AppSync request fields, but it's overwhelming to handle query arguments as they are in JSON in the request and can be objects with arbitrary depth. Example:

{
  "input": {
    "group": {
      "members": []
    }
  }
}

Do you have any suggestion? Thanks by advance.

0

There are 0 answers