Skip to content

Engine config minify_subgraph_operations: false does not prevent minification of graphql payload sent to subgraph #2762

@AndyCa

Description

@AndyCa

Component(s)

router

Component version

0.298.0

wgc version

0.298.0

controlplane version

None

router version

ghcr.io/wundergraph/cosmo/router:0.298.0

What happened?

Description

I am using cosmo router ghcr.io/wundergraph/cosmo/router:0.298.0 with a single subgraph as it allows server sent events over subscriptions. The subgraph is hasura which has an allowed list of queries which I am having to duplicate with an original expanded query and the minified query cosmo router needs due to its auto minification of graphql query payload. I understand it is a good practice to minify the payload for various reasons but in development I would like to be able to use cosmo router without minification of the query.

I understand the ENV var ENGINE_MINIFY_SUBGRAPH_OPERATIONS or config yaml containing option:

engine:
  minify_subgraph_operations: false

should prevent a query such as:

          subscription a {
            report {
              column
            }
          }

being minified to:

subscription a{report{column}}

However, neither the env var or config yaml options are changing anything.

Steps to Reproduce

config.yaml


log_level: debug

dev_mode: ${DEV_MODE}

engine:
  minify_subgraph_operations: false

playground_enabled: ${DEV_MODE}
introspection:
  enabled: ${DEV_MODE}

execution_config:
  file:
    path: "/etc/cosmo/router-config.json"

cors:
  allow_origins:
    - "*"
  allow_methods:
    - "GET"
    - "POST"
    - "PUT"
    - "OPTIONS"
  allow_headers:
    - "content-type"
    - "Authorization"
   

websocket:
  enabled: ${DEV_MODE}
  authentication:
    from_initial_payload:
      enabled: true
      key: "Authorization"
      export_token:
        enabled: true
        header_key: "Authorization"
  forward_upgrade_headers:
    enabled: true
    allow_list: 
      - "Authorization"

headers:
  all:
    request:
      - op: "propagate"
        named: "Authorization"

  subgraphs:
    hasura:
      request:
        - op: "propagate"
          named: "Authorization"

docker-compose.yaml (hasura etc all omitted)

  cosmo-router:
    image: ghcr.io/wundergraph/cosmo/router:0.298.0
    environment:
      CONFIG_PATH: /etc/cosmo/config.yaml
      EXECUTION_CONFIG_FILE_PATH: /etc/cosmo/router-config.json  (generated from my hasura grapql schema)
      LISTEN_ADDR: 0.0.0.0:3002
      DEV_MODE: "true"
      ENGINE_MINIFY_SUBGRAPH_OPERATIONS: "false"   <---tried this but doesn't do anything

Expected Result

Subscription query:

          subscription a {
            report {
              column
            }
          }

is NOT minified to:

subscription a{report{column}}

when ENGINE_MINIFY_SUBGRAPH_OPERATIONS: "false" (or config.yaml is configured correctly).

Actual Result

Env var ENGINE_MINIFY_SUBGRAPH_OPERATIONS or yaml config as specified previously change nothing with regard to query minification and the playground or any curl op returns query is not allowed, where running the same query via the hasura graphql endpoint is fine since the 'expanded' query is in the allowed list:

{
  "errors": [
    {
      "message": "\"error\" message expects the 'payload' property to be an array of GraphQL errors, but got [{\"errors\":[{\"message\":\"query is not allowed\",\"extensions\":{\"path\":\"$\",\"code\":\"validation-failed\"}}]}]",
      "stack": "Error: \"error\" message expects the 'payload' property to be an array of GraphQL errors, but got [{\"errors\":[{\"message\":\"query is not allowed\",\"extensions\":{\"path\":\"$\",\"code\":\"validation-failed\"}}]}]\n    at i (http://localhost:3002/:50:1086686)\n    at ppe.parseMessage (http://localhost:3002/:50:1087618)\n    at i.onmessage (http://localhost:3002/:50:1091597)"
    }
  ]
}

Thanks for your time.

Environment information

Environment

OS: Docker Desktop

Router configuration

Duplicated from above

version: "1"

log_level: debug

dev_mode: ${DEV_MODE}

engine:
  minify_subgraph_operations: false

playground_enabled: ${DEV_MODE}
introspection:
  enabled: ${DEV_MODE}

execution_config:
  file:
    path: "/etc/cosmo/router-config.json"

cors:
  allow_origins:
    - "*"
  allow_methods:
    - "GET"
    - "POST"
    - "PUT"
    - "OPTIONS"
  allow_headers:
    - "content-type"
    - "Authorization"
   

websocket:
  enabled: ${DEV_MODE}
  authentication:
    from_initial_payload:
      enabled: true
      key: "Authorization"
      export_token:
        enabled: true
        header_key: "Authorization"
  forward_upgrade_headers:
    enabled: true
    allow_list: 
      - "Authorization"

headers:
  all:
    request:
      - op: "propagate"
        named: "Authorization"

  subgraphs:
    hasura:
      request:
        - op: "propagate"
          named: "Authorization"

Router execution config

Generated statically from hasura graphql schema

Log output

Playground Logging:

{
  "errors": [
    {
      "message": "\"error\" message expects the 'payload' property to be an array of GraphQL errors, but got [{\"errors\":[{\"message\":\"query is not allowed\",\"extensions\":{\"path\":\"$\",\"code\":\"validation-failed\"}}]}]",
      "stack": "Error: \"error\" message expects the 'payload' property to be an array of GraphQL errors, but got [{\"errors\":[{\"message\":\"query is not allowed\",\"extensions\":{\"path\":\"$\",\"code\":\"validation-failed\"}}]}]\n    at i (http://localhost:3002/:50:1086686)\n    at ppe.parseMessage (http://localhost:3002/:50:1087618)\n    at i.onmessage (http://localhost:3002/:50:1091597)"
    }
  ]
}

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions