use internal_use instead of require_admin for graphql context
This commit is contained in:
parent
e2348aa8f1
commit
25a1129ae4
4 changed files with 6 additions and 6 deletions
|
@ -1,12 +1,12 @@
|
|||
module Types
|
||||
class BaseField < GraphQL::Schema::Field
|
||||
def initialize(*args, require_admin: false, **kwargs, &block)
|
||||
@require_admin = require_admin
|
||||
def initialize(*args, internal: false, **kwargs, &block)
|
||||
@internal = internal
|
||||
super(*args, **kwargs, &block)
|
||||
end
|
||||
|
||||
def visible?(ctx)
|
||||
super && (@require_admin ? ctx[:admin] : true)
|
||||
super && (@internal ? ctx[:internal_use] : true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,7 +24,7 @@ Cela évite l’accès récursif aux dossiers."
|
|||
field :cadre_juridique, String, null: true
|
||||
field :deliberation, String, null: true
|
||||
|
||||
field :dossiers_count, Int, null: false, require_admin: true
|
||||
field :dossiers_count, Int, null: false, internal: true
|
||||
|
||||
def service
|
||||
Loaders::Record.for(Service).load(procedure.service_id)
|
||||
|
|
|
@ -14,7 +14,7 @@ module Types
|
|||
argument :number, Int, "Numéro du groupe instructeur.", required: true
|
||||
end
|
||||
|
||||
field :demarches_publiques, DemarcheDescriptorType.connection_type, null: false, require_admin: true, max_page_size: 30
|
||||
field :demarches_publiques, DemarcheDescriptorType.connection_type, null: false, internal: true, max_page_size: 30
|
||||
|
||||
def demarches_publiques
|
||||
Procedure.opendata
|
||||
|
|
|
@ -23,7 +23,7 @@ class DemarchesPubliquesExportService
|
|||
private
|
||||
|
||||
def execute_query(cursor: nil)
|
||||
result = API::V2::Schema.execute(query, variables: { cursor: cursor }, context: { internal_use: true, admin: true })
|
||||
result = API::V2::Schema.execute(query, variables: { cursor: cursor }, context: { internal_use: true })
|
||||
raise DemarchesPubliquesExportService::Error.new(result["errors"]) if result["errors"]
|
||||
@graphql_data = result["data"]
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue