feat(graphql): prepare avis and messages to handle multiple files
This commit is contained in:
parent
73ff739c52
commit
c008cad1f9
5 changed files with 23 additions and 10 deletions
|
@ -35,13 +35,18 @@ module Extensions
|
|||
if value.respond_to?(:map)
|
||||
attachments = value.map { after_resolve_attachment(_1) }
|
||||
|
||||
if options[:flat_first]
|
||||
if options[:as] == :single
|
||||
attachments.first
|
||||
else
|
||||
attachments
|
||||
end
|
||||
else
|
||||
after_resolve_attachment(value)
|
||||
attachment = after_resolve_attachment(value)
|
||||
if options[:as] == :multiple
|
||||
[attachment]
|
||||
else
|
||||
attachment
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -112,7 +112,8 @@ type Association {
|
|||
}
|
||||
|
||||
type Avis {
|
||||
attachment: File
|
||||
attachment: File @deprecated(reason: "Utilisez le champ `attachments` à la place.")
|
||||
attachments: [File!]!
|
||||
claimant: Profile
|
||||
dateQuestion: ISO8601DateTime!
|
||||
dateReponse: ISO8601DateTime
|
||||
|
@ -1754,7 +1755,8 @@ type LinkedDropDownListChamp implements Champ {
|
|||
}
|
||||
|
||||
type Message {
|
||||
attachment: File
|
||||
attachment: File @deprecated(reason: "Utilisez le champ `attachments` à la place.")
|
||||
attachments: [File!]!
|
||||
body: String!
|
||||
createdAt: ISO8601DateTime!
|
||||
email: String!
|
||||
|
@ -2029,7 +2031,7 @@ type PersonnePhysique implements Demandeur {
|
|||
|
||||
type PieceJustificativeChamp implements Champ {
|
||||
file: File @deprecated(reason: "Utilisez le champ `files` à la place.")
|
||||
files: [File!]
|
||||
files: [File!]!
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
|
@ -2430,4 +2432,4 @@ type ValidationError {
|
|||
A description of the error
|
||||
"""
|
||||
message: String!
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,12 @@ module Types
|
|||
field :date_question, GraphQL::Types::ISO8601DateTime, null: false, method: :created_at
|
||||
field :date_reponse, GraphQL::Types::ISO8601DateTime, null: true, method: :updated_at
|
||||
|
||||
field :attachment, Types::File, null: true, extensions: [
|
||||
field :attachment, Types::File, null: true, deprecation_reason: "Utilisez le champ `attachments` à la place.", extensions: [
|
||||
{ Extensions::Attachment => { attachment: :piece_justificative_file } }
|
||||
]
|
||||
field :attachments, [Types::File], null: false, extensions: [
|
||||
{ Extensions::Attachment => { attachment: :piece_justificative_file, as: :multiple } }
|
||||
]
|
||||
|
||||
field :instructeur, Types::ProfileType, null: false, method: :claimant, deprecation_reason: "Utilisez le champ `claimant` à la place."
|
||||
field :claimant, Types::ProfileType, null: true
|
||||
|
|
|
@ -3,10 +3,10 @@ module Types::Champs
|
|||
implements Types::ChampType
|
||||
|
||||
field :file, Types::File, null: true, deprecation_reason: "Utilisez le champ `files` à la place.", extensions: [
|
||||
{ Extensions::Attachment => { attachments: :piece_justificative_file, flat_first: true } }
|
||||
{ Extensions::Attachment => { attachments: :piece_justificative_file, as: :single } }
|
||||
]
|
||||
|
||||
field :files, [Types::File], null: true, extensions: [
|
||||
field :files, [Types::File], null: false, extensions: [
|
||||
{ Extensions::Attachment => { attachments: :piece_justificative_file } }
|
||||
]
|
||||
end
|
||||
|
|
|
@ -4,9 +4,12 @@ module Types
|
|||
field :email, String, null: false
|
||||
field :body, String, null: false
|
||||
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
|
||||
field :attachment, Types::File, null: true, extensions: [
|
||||
field :attachment, Types::File, null: true, deprecation_reason: "Utilisez le champ `attachments` à la place.", extensions: [
|
||||
{ Extensions::Attachment => { attachment: :piece_jointe } }
|
||||
]
|
||||
field :attachments, [Types::File], null: false, extensions: [
|
||||
{ Extensions::Attachment => { attachment: :piece_jointe, as: :multiple } }
|
||||
]
|
||||
|
||||
def body
|
||||
object.body.nil? ? "" : object.body
|
||||
|
|
Loading…
Reference in a new issue