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

Fields from other type in union appearing in output as null #1211

Closed
guymers opened this issue Dec 16, 2021 · 3 comments · Fixed by #1213
Closed

Fields from other type in union appearing in output as null #1211

guymers opened this issue Dec 16, 2021 · 3 comments · Fixed by #1213
Labels
bug Something isn't working server Issue related to caliban server

Comments

@guymers
Copy link
Contributor

guymers commented Dec 16, 2021

Given the following schema:

schema {
  query: Test
}

union Base = BaseOne | BaseTwoOne

type BaseOne {
  id: String!
  name: String!
  inner: [BaseOneInner!]!
}

type BaseOneInner {
  a: String!
}

type BaseTwoInner {
  b: Int!
}

type BaseTwoOne {
  id: String!
  name: String!
  inner: [BaseTwoInner!]!
}

type Test {
  bases: [Base!]!
}

Running the following query:

query {
  bases {
    ... on BaseOne {
      id
      name
      inner { a }
    }
    ... on BaseTwoOne {
      id
      name
      inner { b }
    }
  }
}

Produces the following output since 1.3.1

{
  "bases": [
    {
      "id": "1",
      "name": "base 1",
      "inner": [
        {
          "a": "a",
          "b": null
        }
      ]
    },
    {
      "id": "2",
      "name": "base 2",
      "inner": [
        {
          "a": null,
          "b": 2
        }
      ]
    }
  ]
}

Note the "b": null in item 0 and "a": null in item 1.

Basic test case: https://gist.github.com/guymers/bce14ace58e2c6c57f594f7be1981536

@ghostdogpr
Copy link
Owner

ghostdogpr commented Dec 16, 2021

Ah, I see what's going on. When merging fields, if there are 2 conditional fields with the same name, I should bubble down the condition to the children. Thanks for the report.

I'm traveling today so I should be able to get it fixed tomorrow.

@ghostdogpr ghostdogpr added bug Something isn't working server Issue related to caliban server core labels Dec 16, 2021
@ghostdogpr
Copy link
Owner

@guymers I just merged the fix. A snapshot will be generated within 10 minutes. Can you check if this works well for you?

@guymers
Copy link
Contributor Author

guymers commented Dec 19, 2021

Can confirm that the fix solves the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working server Issue related to caliban server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants