ChilliCream / graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
https://chillicream.com
MIT License
5.26k stars 745 forks source link

@resolve produces incorrect query in fusion graph when the field name differs from the query name #6579

Closed ktrauberman closed 1 year ago

ktrauberman commented 1 year ago

Is there an existing issue for this?

Product

Hot Chocolate

Describe the bug

I have a subgraph "A" that has a query widgetById(widgetId: ID!): Widget! and another subgraph "B" that has a type with a widgetId field type Thing { widgetId: ID! }. I want to extend this type with a field widgetName that is resolved from the Widget.name field.

I added this to schema.extensions.graphql in subgraph "A"

extend type Thing
{
    widgetName(widgetId: ID! @require(field: "widgetId")): String @resolve(select: "widgetById(widgetId: $widgetId) { name }")
}

which produces this in the fusion graph:

  widgetName: String
    @source(subgraph: "SubgraphA")
    @variable(subgraph: "SubgraphB", name: "Thing_widgetId", select: "widgetId")
    @resolver(subgraph: "SubgraphA", select: "{ widgetName(widgetId: $Thing_widgetId) }", arguments: [ { name: "Thing_widgetId", type: "ID!" } ])

and when I try to query that field, I get an error:

    {
      "message": "The field `widgetName` does not exist on the type `Query`.",
      "locations": [
        {
          "line": 1,
          "column": 46
        }
      ],
      "extensions": {
        "type": "Query",
        "field": "widgetName",
        "responseName": "widgetName",
        "specifiedBy": "http://spec.graphql.org/October2021/#sec-Field-Selections-on-Objects-Interfaces-and-Unions-Types"
      }
    }

I would expect the fusion graph to produce the query that I'm passing into the @resolve directive.

Steps to reproduce

Relevant log output

No response

Additional Context?

No response

Version

13.6.0-preview.23

michaelstaib commented 1 year ago

resolve is not yet supported..... so no bug here.

ktrauberman commented 1 year ago

resolve is not yet supported..... so no bug here.

Alright. What is the proper way to do what I'm attempting then? There's no documentation for fusion so I'm fumbling around in the dark here.

ktrauberman commented 1 year ago

Will this PR add the proper features to do what I'm trying to do here?