DataPower API Gateway
only

Request mechanisms supported by GraphQL endpoints

API Connect supports various mechanisms for sending requests to GraphQL proxy API endpoints.

You can use any of the following mechanisms for sending requests to the /graphql and /graphql/cost endpoints on a GraphQL proxy API:

  • GET: the GraphQL query must be specified in a URL query parameter called query.
    For example:
    https://hostname/basepath/graphql?query={accounts(limit:100){name{first,last}}}
    The following example includes the variables and operationName properties, with URL encoding:
    https://hostname/basepath/graphql?query=query%20fetchAccounts%20($limit:%20Int)%20{accounts(limit:%20$limit)%20{name{first,last}}}&variables={"limit":100}&operationName=fetchAccounts
  • POST with a JSON-encoded body: the Content-Type header must be set to application/json, and the GraphQL query must be sent in the query key of the JSON object.
    For example:
    {
      "query": "query fetchAccounts ($limit: Int) {accounts(limit: $limit) {name{first,last}}}",
      "variables": {"limit": 100},
      "operationName": "fetchAccounts"
    }

    The variables and operationName are optional. For more information, see POST request in the GraphQL documentation at https://graphql.org/..

  • POST with graphql content: the Content-Type header must be set to application/graphql; the entire body of the POST is treated as the GraphQL query
Note: For a request sent to the /graphql endpoint, the GraphQL proxy API always sends the request to the backend GraphQL server as a POST with a JSON-encoded body, so the backend GraphQL server must support this mechanism otherwise the call fails.