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

How to change names of queries and mutations ? #196

Open
maszuDEV opened this issue Sep 7, 2021 · 5 comments
Open

How to change names of queries and mutations ? #196

maszuDEV opened this issue Sep 7, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@maszuDEV
Copy link

maszuDEV commented Sep 7, 2021

Question

Hello everyone,

In my case, I have a user model like: User::Model, which is generating mutations named, e.g. userModelLogin.

Is there any option to change the way how queries and mutations are naming? I would like to have just userLogin.

Best regards!

@00dav00
Copy link
Contributor

00dav00 commented Sep 7, 2021

Hi @maszuDEV , the names of the default operations will use the class and namespace, check these links for reference:

I think a work around for your case could be to add additional_mutations and additional_queries with the names you are looking for. Please take a look at the README sections for this:

Remember that only or skip (they are mutually exclusive) can also help you choose which of the default operations you want to be mounted on the schema.

@maszuDEV
Copy link
Author

maszuDEV commented Sep 7, 2021

@00dav00 This is what I needed! Works great, thanks a lot!

@maszuDEV maszuDEV closed this as completed Sep 7, 2021
@00dav00
Copy link
Contributor

00dav00 commented Sep 7, 2021

Good to know @maszuDEV !

@mcelicalderon
Copy link
Member

We should probably add a simpler way to rename queries...

Another way to do this if you are using the plugin to mount this gem in your own schema, would be to create your own login mutation that inherits from the one included in this gem, and use it in you own mutation type with the name you like. Like we do in here:

class Login < GraphqlDevise::Mutations::Login

then, in your mutationType file you would just do:

field :user_login, mutation: Mutations::Login, authenticate: false

@mcelicalderon
Copy link
Member

mcelicalderon commented Sep 8, 2021

@00dav00 reopening this one as a feature request. Changing names of the queries should be straightforward and a nice addition. Perhaps something in the resource loaders like:

GraphqlDevise::ResourceLoader.new(User, only: [:login, :confirm_registration_with_token], custom_names: { login: :my_user_login_custom_mutation })

WDYT?

@mcelicalderon mcelicalderon reopened this Sep 8, 2021
@mcelicalderon mcelicalderon added the enhancement New feature or request label Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants