Skip to content
This repository has been archived by the owner on May 16, 2019. It is now read-only.

Fragments not resolving correctly on same data node #49

Open
puug opened this issue Jan 11, 2019 · 0 comments
Open

Fragments not resolving correctly on same data node #49

puug opened this issue Jan 11, 2019 · 0 comments

Comments

@puug
Copy link

puug commented Jan 11, 2019

Having an issue where fragments that operate on the same data node are not being merged, rather only the last fragment is being resolved.

Setup

data class Contact(val name: Name = Name())
data class Name(val firstName: String = "Bob", val lastName: String = "Jones")
 KGraphQL.schema {
        query("contact") {
            resolver { -> Contact() }
        }

        type<Contact> { }
}

A simple query resolves correctly

{
  contact {
    name {
      firstName
      lastName
    }
  }
}

Result

{
  "data": {
    "contact": {
      "name": {
        "firstName": "Bob",
        "lastName": "Jones"
      }
    }
  }
}

But when multiple fragments are used that operate on name only the last is resolved

fragment firstName on Contact {
  name {
    firstName
  }
}

fragment lastName on Contact {
  name {
    lastName
  }
}

{
  contact {
     ...firstName
     ...lastName
  }
}

Result

{
  "data": {
    "contact": {
      "name": {
        "lastName": "Jones"
      }
    }
  }
}

The fragments work as expected when used independently, and if they operate on different nodes of data they both resolve.

Expected
Both fragment should be resolved and firstName and lastName returned. That's my understanding of the spec, and I ran a similar experiment against express-graphql and it merges correctly. This leads me to believe it's a bug within KGraphQL.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant