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

Allow aliases in GraphQL forwarding. #28

Open
illegalprime opened this issue Oct 5, 2017 · 0 comments
Open

Allow aliases in GraphQL forwarding. #28

illegalprime opened this issue Oct 5, 2017 · 0 comments

Comments

@illegalprime
Copy link
Member

Currently aliasing in a forwarded query does not work well:

query UserSearch($text: String!, $number: Int!) {
  search_user(search: $text, offset: 0, n: $number) {
    user {
      ...UserFragment
    }
  }
}

fragment UserFragment on User {
  id
  name
  email
  school: question(name: "school") {
    value
  }
}

Here the UserFragment is forwarded to registration and registration returns an object containing the keys { id name email school }, but GraphQL expects school to be named question so it can itself rename it to school. This is a little more tricky since one must first find which aliases map to which fields and then when multiple aliases for the same thing are in place it has to remember all of them somehow (because they can't be returned all at once, GraphQL will repeatedly call the method with the different alias variants). This could probably be done by some smart caching of the query to the results, then removing the cache when all the results have been returned.

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

No branches or pull requests

1 participant