Skip to content

Stitched schema does return "null" for aliased fields in union types #4394

Open
@xddq

Description

@xddq

Issue workflow progress

Progress of the issue based on the Contributor Workflow

  • 1. The issue provides a reproduction available on Github here
  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

  • Aliased attributes in union types resolve to null instead of their correct value when using schema stitching to combine two remote schemas.
  • The same query returns the correct result on the "non-stitched" schema when issued to the non-stitched schema at localhost:/4001/graphql

To Reproduce
Steps to reproduce the behavior:

  • checkout the github repo
  • follow the README.md steps:
    • npm i && npm run start
    • gateway on localhost:4444/graphql
    • remote-1 on localhost:4001/graphql
    • remote-2 on localhost:4002/graphql
  • go to localhost:4444/graphql (the stitched schema) and query
query {articles {title {
 ... on TitleOne {text}
 ... on TitleTwo {renamedText: text}
}}}

Expected behavior

  • result should contain correct values. E.g.
{
  "data": {
    "articles": [
      {
        "title": {
          "text": "hello world"
        }
      },
      {
        "title": {
          "renamedText": 1
        }
      },
      {
        "title": {
          "renamedText": 2
        }
      },
      {
        "title": {
          "text": "bye"
        }
      }
    ]
  }
}

** Actual Behaviour **

  • result contains "null" for aliased fields
{
  "data": {
    "articles": [
      {
        "title": {
          "text": "hello world"
        }
      },
      {
        "title": {
          "renamedText": null
        }
      },
      {
        "title": {
          "renamedText": null
        }
      },
      {
        "title": {
          "text": "bye"
        }
      }
    ]
  }
}

Environment:

  • OS: ubuntu 18.04
  • "@graphql-tools/load": "^7.5.8",
  • "@graphql-tools/schema": "^8.3.8",
  • "@graphql-tools/stitch": "^8.6.6",
  • "@graphql-tools/url-loader": "^7.9.11",
  • "@graphql-tools/wrap": "^8.4.13",
  • NodeJS: v14.19.1

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions