-
Notifications
You must be signed in to change notification settings - Fork 45
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
Override graphql_name
to allow for shared mutations
#225
Comments
Hi @TomasBarry , I see your point here, I guess the About using a single mutation to login all resources, there are 2 things that I would like to mention:
|
Hi, I'm having the same issue with two authenticatable models. I thought I could share the same mutation between them by using the I have no issue with duplicating code in the meantime, but I'm worried that I could accidentally share logins between different models. Would it be safe to do this? (in the sense that class SchemaA < GraphQL::Schema # this one is public
use GraphqlDevise::SchemaPlugin.new(
query: Types::QueryTypeA,
mutation: Types::MutationTypeA,
public_introspection: true,
resource_loaders: [
GraphqlDevise::ResourceLoader.new(
User,
only: %i[
login
logout
register
update_password_with_token
send_password_reset_with_token
confirm_registration_with_token
],
operations: {
login: Mutations::UserLogin,
}
)
]
)
# ...etc
end class SchemaB < GraphQL::Schema # this one is private
use GraphqlDevise::SchemaPlugin.new(
query: Types::QueryTypeB,
mutation: Types::MutationTypeB,
resource_loaders: [
GraphqlDevise::ResourceLoader.new(
Admin,
only: %i[
login
logout
],
operations: {
login: Mutations::AdminLogin
}
)
]
)
# ...etc
end |
What is the problem the enhancement will solve?
In our system, we have multiple different resources. We would like to have a single mutation per operation that can be shared between the various resources.
Essentially, be able to use a Union Type for the authenticable resource where all resources can share a common mutation rather than having to implement one mutation per resource per operation.
Describe the solution you have in mind
Allow for the overriding of
graphql_name
in a custom mutation that inherits from one of theGraphQLDevise
operations:Then the schema file can mount resources like:
Describe alternatives you've considered
One mutation per resource.
Additional context
It seems that there is no customisation of the mutation name available in https://github.com/graphql-devise/graphql_devise/blob/v0.18.2/lib/graphql_devise/mount_method/operation_preparers/default_operation_preparer.rb
It appears that the above ignores any custom
graphql_name
setting in a mutation linked to an operation.The text was updated successfully, but these errors were encountered: