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

Add support for multiple fragments merging in ReplaceFieldWithFragment #894

Closed
maticzav opened this issue Jul 17, 2018 · 1 comment
Closed
Labels
feature New addition or enhancement to existing solutions

Comments

@maticzav
Copy link
Contributor

Hello 👋,

This is a feature request for supporting automatical merging of multiple fragments with same field and typeCondition.

Transform

const transforms = [
  new ReplaceFieldWithFragment(subSchema, [
    {
      field: `fullname`,
      fragment: `fragment UserName on User { name }`,
    },
    {
      field: `fullname`,
      fragment: `fragment UserSurname on User { surname }`,
    },
  ]),
]
query {
  userById(id: "ID") {
    fullname
  }
}

Expected behaviour

query {
  someQuery(id: "ID") {
    ...on User {
      name
      surname
    }
  }
}

Actual Behaviour

query {
  someQuery(id: "ID") {
    ...on User {
      surname
    }
  }
}

This happens due to default overwriting of the fragments instead of collecting them.

Use cases

  • GraphQL Binding - this would enable overlapping fragmentReplacements which have to be handled manually at the moment.
  • GraphQL Middleware - this would enable fragments support in graphql-middleware where we need support for a list of different fragmentsReplacements extracted from different middleware.
@yaacovCR
Copy link
Collaborator

yaacovCR commented Apr 1, 2020

Closed by #895

@yaacovCR yaacovCR closed this as completed Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New addition or enhancement to existing solutions
Projects
None yet
Development

No branches or pull requests

2 participants