Merge pull request #8439 from tchak/fix-graphql-dossier-n+1
fix(graphql): n+1 on single dossier loading
This commit is contained in:
commit
ca4f597c13
1 changed files with 2 additions and 1 deletions
|
@ -38,11 +38,12 @@ module Types
|
|||
end
|
||||
|
||||
def dossier(number:)
|
||||
if context.internal_use?
|
||||
dossier = if context.internal_use?
|
||||
Dossier.state_not_brouillon.for_api_v2.find(number)
|
||||
else
|
||||
Dossier.visible_by_administration.for_api_v2.find(number)
|
||||
end
|
||||
DossierPreloader.load_one(dossier)
|
||||
rescue => e
|
||||
raise GraphQL::ExecutionError.new(e.message, extensions: { code: :not_found })
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue