Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL POST - Query configuration user body values are not overriding default values. #801

Open
vox-tone opened this issue Oct 19, 2023 · 3 comments
Labels

Comments

@vox-tone
Copy link

Environment info:

  • KrakenD version: 2.4.6
  • System info: docker
  • Hardware specs: 6 CPU, 12Gi
  • Backend technology: Node
  • Additional environment information:
    Using docker image devopsfaith/krakend:2.4.6 calling postgraphile backend.

Describe the bug
GraphQL POST - Query configuration user body values are not overriding default values provided in configuration file.
I am following the instructions on GraphQL POST + Query here...
https://www.krakend.io/docs/backends/graphql/#post--query

KrakenD is calling out to the backend GraphQL endpoint (postgraphile) and returning data with the default variable values set in the configuration file. However, when sending POST requests with values designed to override the default GraphQL query values, KrakenD does not replace the values.

I have successfully configured KrakenD to work with URL variables
( Eg. http://localhost:8080/data/foo "variables": { "id": "{id}"}
I have also successfully configured KrakenD to work when the query 'type' is 'mutation'. However, when "type": "query", the user variables presented in the body do not replace the defaults.

Your configuration file:

{
    "version": 3,
    "name": "My Fab Gateway",
    "port": 8080,
    "endpoints": [
        {
            "endpoint": "/data",
            "method": "POST",
            "backend": [
                {
                    "timeout": "3100ms",
                    "url_pattern" "/graphql",
                    "host": [
                        "http://localhost:5000/"
                   ],
                   "extra_config": {
                    "backend/graphql": {
                        "type": "query",
                        "query_path": "./test.graphql",
                        "operationName": "QueryData",
                        "variables": {
                            "id": "foo"
                        }
                    }
                   }
                }
            ]
        }
    ]
}

Commands used
How did you start the software?

docker run --network host -p 8080:8080 -v $PWD:/etc/krakend/ devopsfaith/krakend:2.4.6

Calling the endpoint using curl

curl -XPOST -d '{ "id": "bar" }' http://localhost:8080/data

Expected behavior
GraphQL query is made with variables replaced with those provided in the user body.

variables: {
  "id": "bar"
}

Logs

Additional context
contents of test.graphql

query QueryData ($id: ID!) {
  data(id: $id) {
    name
  }
}
Copy link

This issue is marked as stale because it has been open over 90 days with no activity. Remove the stale label or comment or this will be closed in 15 days.

@github-actions github-actions bot added the stale label Jan 17, 2024
@alombarte
Copy link
Member

Hi @vox-tone , the example in the documentation was misleading, it has been corrected.

@github-actions github-actions bot removed the stale label Jan 20, 2024
Copy link

This issue is marked as stale because it has been open over 90 days with no activity. Remove the stale label or comment or this will be closed in 15 days.

@github-actions github-actions bot added the stale label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants