require admin context for demarchesPubliques field
This commit is contained in:
parent
78d772441b
commit
fa1cbdc848
2 changed files with 15 additions and 1 deletions
12
app/graphql/types/base_field.rb
Normal file
12
app/graphql/types/base_field.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
module Types
|
||||
class BaseField < GraphQL::Schema::Field
|
||||
def initialize(*args, require_admin: false, **kwargs, &block)
|
||||
@require_admin = require_admin
|
||||
super(*args, **kwargs, &block)
|
||||
end
|
||||
|
||||
def visible?(ctx)
|
||||
super && (@require_admin ? ctx[:admin] : true)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,5 +1,7 @@
|
|||
module Types
|
||||
class QueryType < Types::BaseObject
|
||||
field_class BaseField
|
||||
|
||||
field :demarche, DemarcheType, null: false, description: "Informations concernant une démarche." do
|
||||
argument :number, Int, "Numéro de la démarche.", required: true
|
||||
end
|
||||
|
@ -12,7 +14,7 @@ module Types
|
|||
argument :number, Int, "Numéro du groupe instructeur.", required: true
|
||||
end
|
||||
|
||||
field :demarches_publiques, DemarcheDescriptorType.connection_type, null: false
|
||||
field :demarches_publiques, DemarcheDescriptorType.connection_type, null: false, require_admin: true
|
||||
|
||||
def demarches_publiques
|
||||
Procedure.publiques
|
||||
|
|
Loading…
Reference in a new issue