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

Query Name Rewriter #15

Open
irfanalef2060 opened this issue Feb 18, 2020 · 5 comments
Open

Query Name Rewriter #15

irfanalef2060 opened this issue Feb 18, 2020 · 5 comments

Comments

@irfanalef2060
Copy link

First of all this is not an issue, I need a little bit of help.

I didn't find a rewriter for the query name.

Example:
Let say we have query like this which is being used in many clients
query query getUserById($id: String!) { userById(id: $id) { ... } }

I want to change my query to this
query getCurrentUserByID($id: String!) { userById(id: $id) { ... } }

So I want that whenever client query getUserById, it should map to getCurrentUserByID. I think currently there is no option for query name. So is there any problem with writing a rewriter for query name? Have you tried this? Because I am thinking to write a query rewriter for this.

@chanind
Copy link
Collaborator

chanind commented Feb 19, 2020

This was also requested in #14. Currently there's no rewriter for this since you can deprecate the old field and make a new field with the new name using normal graphQL deprecationReason, but I think it's fine to add if it's something people want to use. As discussed in the existing PR, it will require changing some internals to make this rewriter possible.

@irfanalef2060
Copy link
Author

@chanind Thanks for the reply. I checked out the PR. I went through code as well of rewrite a response. I found out that its more related to work with rewriteScalarFieldToObjectField and NestFieldOutputsRewriter. To make it work FieldNameRewrite won't be straight away. I am trying to make it work with it.
Any suggestions would be appreciated.

@gregbty
Copy link
Contributor

gregbty commented Sep 3, 2020

@chanind did you already have something in mind for updating the rewriter? I could submit a pull request for it. I've created a version of the field name rewriter but the only thing missing is the ability to rewrite the response.

@gregbty
Copy link
Contributor

gregbty commented Sep 4, 2020

See #20.

@chanind
Copy link
Collaborator

chanind commented Sep 8, 2020

Thanks @gregbty! Sorry for the delay getting back on this! Just a minor naming nit on the PR and should be good to merge.

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

No branches or pull requests

3 participants