Include AuthorizeResource module for all mutations
This makes our authorization calls available to all GraphQL mutations without the additional step of including the module first.
This commit is contained in:
parent
056166db0a
commit
67030789f5
|
@ -3,8 +3,6 @@
|
||||||
module Mutations
|
module Mutations
|
||||||
module AwardEmojis
|
module AwardEmojis
|
||||||
class Base < BaseMutation
|
class Base < BaseMutation
|
||||||
include Gitlab::Graphql::Authorize::AuthorizeResource
|
|
||||||
|
|
||||||
authorize :award_emoji
|
authorize :award_emoji
|
||||||
|
|
||||||
argument :awardable_id,
|
argument :awardable_id,
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
module Mutations
|
module Mutations
|
||||||
class BaseMutation < GraphQL::Schema::RelayClassicMutation
|
class BaseMutation < GraphQL::Schema::RelayClassicMutation
|
||||||
|
prepend Gitlab::Graphql::Authorize::AuthorizeResource
|
||||||
prepend Gitlab::Graphql::CopyFieldDescription
|
prepend Gitlab::Graphql::CopyFieldDescription
|
||||||
|
|
||||||
field :errors, [GraphQL::STRING_TYPE],
|
field :errors, [GraphQL::STRING_TYPE],
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
module Mutations
|
module Mutations
|
||||||
module MergeRequests
|
module MergeRequests
|
||||||
class Base < BaseMutation
|
class Base < BaseMutation
|
||||||
include Gitlab::Graphql::Authorize::AuthorizeResource
|
|
||||||
include Mutations::ResolvesProject
|
include Mutations::ResolvesProject
|
||||||
|
|
||||||
argument :project_path, GraphQL::ID_TYPE,
|
argument :project_path, GraphQL::ID_TYPE,
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
module Mutations
|
module Mutations
|
||||||
module Notes
|
module Notes
|
||||||
class Base < BaseMutation
|
class Base < BaseMutation
|
||||||
include Gitlab::Graphql::Authorize::AuthorizeResource
|
|
||||||
|
|
||||||
field :note,
|
field :note,
|
||||||
Types::Notes::NoteType,
|
Types::Notes::NoteType,
|
||||||
null: true,
|
null: true,
|
||||||
|
|
|
@ -424,12 +424,8 @@ Will generate a field called `mergeRequestSetWip` that
|
||||||
|
|
||||||
### Authorizing resources
|
### Authorizing resources
|
||||||
|
|
||||||
To authorize resources inside a mutation, we can include the
|
To authorize resources inside a mutation, we first provide the required
|
||||||
`Gitlab::Graphql::Authorize::AuthorizeResource` concern in the
|
abilities on the mutation like this:
|
||||||
mutation.
|
|
||||||
|
|
||||||
This allows us to provide the required abilities on the mutation like
|
|
||||||
this:
|
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
module Mutations
|
module Mutations
|
||||||
|
|
Loading…
Reference in New Issue