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

Routing error when directly fetching properties on interfaces #1442

Open
alexus37 opened this issue Dec 13, 2024 · 3 comments
Open

Routing error when directly fetching properties on interfaces #1442

alexus37 opened this issue Dec 13, 2024 · 3 comments
Labels
bug Something isn't working internally-reviewed The issue has been reviewed internally.

Comments

@alexus37
Copy link

alexus37 commented Dec 13, 2024

Component(s)

router

router version

v0.0.0-20240927172855-3e390cd5cf6c

What happened?

Description

The router is encountering an error when I try to retrieve the query plan for queries that directly fetch data from interfaces.

Steps to Reproduce

Execute a query like this:

{
  repository(name: "<REDACTED>", owner: "<REDACTED>") {
    issue(number: 1) {
      timelineItems(since: "<REDACTED>", first: 1) {
        edges {
          node {
            ... on Comment {
              id
              bodyText
            }
          }
        }
      }
    }
  }
}

where the Comment is an interface and not a type.

interface Comment {
  
  """
  The body rendered to text.
  """
  bodyText: String!

  """
  The Node ID of the Comment object
  """
  id: ID!
}

Expected Result

The correct query plan is being returned! This works perfectly when I directly fetch data from a type that implements that interface or when I simply retrieve the ID.

Actual Result

We are getting a execution plan failure.

Environment information

I am using the following headers:

{
  "X-WG-TRACE": "false",
  "X-WG-Skip-Loader": "true",
  "X-WG-Include-Query-Plan": "true",
}

Log output

AM ERROR internal error {"error": "1 error occurred:\n\t* could not resolve a field: internal: nodesResolvableVisitor: could not select the datasource to resolve Repository.__typename on path query.repository.__typename\n\n"}
@alexus37 alexus37 added the bug Something isn't working label Dec 13, 2024
Copy link

WunderGraph commits fully to Open Source and we want to make sure that we can help you as fast as possible.
The roadmap is driven by our customers and we have to prioritize issues that are important to them.
You can influence the priority by becoming a customer. Please contact us here.

@Noroth Noroth added the internally-reviewed The issue has been reviewed internally. label Dec 17, 2024
@apatelWU
Copy link

apatelWU commented Dec 19, 2024

I am facing similar issue as well where __typename required on interface object when fetching Id. If we are fetch other attributes of interface, then its working as expected.

For instance:
SubGraph A

interface A {
  a1Field: ID!
  a2Field: String
  a3Field: String
}

type XA implements A {
  a1Field: ID!
  a2Field: String
  a3Field: String
  xa1Field: String
}

type XB implements A {
  a1Field: ID!
  a2Field: String
  a3Field: String
  xb1Field: String
}

SubGraph B

type B {
  b1Field: ID!
  b2Field: String
  a: A!
}

query details:

query Test {
  b(id: ID!) {
    b1Field
    b2Field
    a {
      a1Field
    }
  }
}

The above query returns following error:
Subgraph 'B' returned invalid value 'A' for __typename field.

QueryPlan {
    SingleFetch(service: "B") {
        {
            b(id: $Id) {
                b1Field
                b2Field
                a {
                    __typename
                    a1Field
                }
            }
        }
    }
}

However, following queries returns data as expected

query Test {
  b(id: ID!) {
    b1Field: ID!
    b2Field: String
    a {
      a1Field
      a2Field
    }
  }
}

or

query Test {
  b(id: ID!) {
    b1Field: ID!
    b2Field: String
    a {
      __typename
      a1Field
    }
  }
}

@YassineElbouchaibi
Copy link
Contributor

Noticed the same thing while creating repro for #1440.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working internally-reviewed The issue has been reviewed internally.
Projects
None yet
Development

No branches or pull requests

4 participants