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

Gateway is sending argument default values to subgraphs #6753

Closed
1 task done
tobias-tengler opened this issue Dec 6, 2023 · 0 comments · Fixed by #6767
Closed
1 task done

Gateway is sending argument default values to subgraphs #6753

tobias-tengler opened this issue Dec 6, 2023 · 0 comments · Fixed by #6767
Labels
Area: Fusion Issue is related to Hot Chocolate Fusion 🌶️ hot chocolate

Comments

@tobias-tengler
Copy link
Collaborator

tobias-tengler commented Dec 6, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Product

Hot Chocolate

Describe the bug

In the past few weeks we've seen two cases where the Gateway would completely error for seemingly unproblematic queries, while we were removing (in these queries unused) arguments with a default value from our subgraphs.

In the time window between the subgraph without the argument being deployed, the gateway still knowing about the argument and clients sending requests without that argument, we saw that the gateway would send the default value of the argument to the subgraph even though the argument wasn't set in the user's query.

Of course this leads to an error, since the subgraph no longer defines the argument, so the query is rejected as being invalid, even though the raw user query would execute just fine against the subgraph.

This makes it impossible to remove arguments without downtime.

Steps to reproduce

I've created this test as a reproduction:

[Fact]
public async Task Test()
{
    // arrange
    var fusionGraph = await FusionGraphComposer.ComposeAsync(
        new[]
        {
            new SubgraphConfiguration(
                "Test",
                """
                type Query {
                    test(arg: TestEnum = VALUE2): Boolean
                }

                enum TestEnum {
                    VALUE1,
                    VALUE2
                }
                """,
                "",
                new []
                {
                    new HttpClientConfiguration(new Uri("http://client"), "Test")
                },
                null)
        });

    // act
    var result = await CreateQueryPlanAsync(
        fusionGraph,
        """
        query Test {
          test
        }
        """);

    // assert
    var snapshot = new Snapshot();
    snapshot.Add(result.UserRequest, nameof(result.UserRequest));
    snapshot.Add(result.QueryPlan, nameof(result.QueryPlan));
    await snapshot.MatchAsync();
}

If you look at the test output or rather the query plan of the { test } query, you can see that the gateway plans the following query:

query Test_1 { test(arg: VALUE2) }

I don't see why the gateway should hardcode the default value.

Full test output:

UserRequest
---------------
query Test {
  test
}
---------------

QueryPlan
---------------
{
  "document": "query Test { test }",
  "operation": "Test",
  "rootNode": {
    "type": "Sequence",
    "nodes": [
      {
        "type": "Resolve",
        "subgraph": "Test",
        "document": "query Test_1 { test(arg: VALUE2) }",
        "selectionSetId": 0
      },
      {
        "type": "Compose",
        "selectionSetIds": [
          0
        ]
      }
    ]
  }
}
---------------

Relevant log output

No response

Additional Context?

No response

Version

14.0.0-p.15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Fusion Issue is related to Hot Chocolate Fusion 🌶️ hot chocolate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants