Skip to content

Accept requests where query is a parsed AST representation #279

@terion-name

Description

@terion-name

Hello.

When using apollo or weaver graphql tools (as proxies and gateways), they are parsing input graphql and sending already parsed request. This works ok with node-js or scala servers, but with php server (this one) it breaks with GraphQL query body is expected to be string, but got array at /app/vendor/webonyx/graphql-php/src/Utils/Utils.php:231.
Why this queries are not supported (while reference implementation supports it) and is there a way to make it work? In other words, is there a way to map this structure to DocumentNode?

Example request body:

{
  "query": {
    "kind": "Document",
    "definitions": [
      {
        "kind": "OperationDefinition",
        "operation": "query",
        "variableDefinitions": [],
        "selectionSet": {
          "kind": "SelectionSet",
          "selections": [
            {
              "kind": "Field",
              "name": {
                "kind": "Name",
                "value": "municipalityByDomain",
                "loc": {
                  "start": 28,
                  "end": 48
                }
              },
              "arguments": [
                {
                  "kind": "Argument",
                  "name": {
                    "kind": "Name",
                    "value": "domain",
                    "loc": {
                      "start": 49,
                      "end": 55
                    }
                  },
                  "value": {
                    "kind": "StringValue",
                    "value": "foo",
                    "block": false,
                    "loc": {
                      "start": 57,
                      "end": 62
                    }
                  },
                  "loc": {
                    "start": 49,
                    "end": 62
                  }
                }
              ],
              "directives": [],
              "selectionSet": {
                "kind": "SelectionSet",
                "selections": [
                  {
                    "kind": "Field",
                    "name": {
                      "kind": "Name",
                      "value": "id",
                      "loc": {
                        "start": 72,
                        "end": 74
                      }
                    },
                    "arguments": [],
                    "directives": [],
                    "loc": {
                      "start": 72,
                      "end": 74
                    }
                  }
                ]
              },
              "loc": {
                "start": 28,
                "end": 80
              }
            }
          ]
        }
      }
    ]
  },
  "variables": {},
  "context": {
    "graphqlContext": {}
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions