My mutation as follows
mutation createNotes($content:String!,$entityId:String!,$entityType:String!,$mentionUserId:String!
,$mentionUserType:String!) {
createNote( note: {
content: $content
entityId: $entityId,
entityType: $entityType
mentionedUserIds: [{
id: $mentionUserId
type: $mentionUserType
}]
} ) {
id
}
}
My mutation call from activity
val response = apolloClientNotes.mutation(
CreateNotesMutation(
content=content,
entityId = entityId,
entityType=notesEntity,
mentionUserId=mentionUserId,
mentionUserType=mentionUserType
)
).execute()
I need to pass the mentionedUserIds as array of objects, I don’t know how to pass.
Hi!
Instead of having your GraphQL mutation accepting a String!
argument, make it accept a list of your input type. Then in its body, pass the list directly.
So, assuming the input type is named MentionUserId
, something like:
mutation createNotes($content: String!, $entityId: String!, $entityType: String!, $mentionUserIds:[MentionUserId!]!) {
createNote( note: {
content: $content
entityId: $entityId,
entityType: $entityType
mentionUserIds: $mentionUserIds
) {
id
}
Hope this helps!
Manikandan_Balakrish:
val response = apolloClientNotes.mutation(
CreateNotesMutation(
content=content,
entityId = entityId,
entityType=notesEntity,
mentionUserId=mentionUserId,
mentionUserType=mentionUserType
)
).execute()
Hi Benoit,
How can I pass the list from the api call, as json? will that work?
val response = apolloClientNotes.mutation(
CreateNotesMutation(
content=content,
entityId = entityId,
entityType=notesEntity,
mentionUserIds = mentionUserIds
)
).execute()
mutation createNotes($content:String!,$entityId:String!,$entityType:String!,$user_array: [NoteMentionedUserDTO!]!) {
createNote( note: {
content: $content
entityId: $entityId,
entityType: $entityType
mentionedUserIds: $user_array
} ) {
id
}
}
my schema contains the following
type Mutation {
createNote(note: NoteCreateDTO!): Note!
updateNote(id: String!, note: NoteUpdateDTO!): Note!
deleteNote(id: String!): String!
createVendorNote(note: VendorNoteCreateDTO!): Note!
updateVendorNote(id: String!, note: VendorNoteUpdateDTO!): Note!
deleteVendorNote(id: String!, note: VendorNoteDeleteDTO!): String!
}
input NoteCreateDTO {
content: String!
entityType: String!
entityId: String!
mentionedUserIds: [NoteMentionedUserDTO!]
createdByType: String
redirectURL: String
}
input NoteMentionedUserDTO {
id: String!
type: String!
}
You should be able to pass a list of NoteMentionedUserDTO
to the generated Mutation, something like:
val response = apolloClientNotes.mutation(
CreateNotesMutation(
content = "",
entityId = "",
entityType = "",
user_array = listOf(
NoteMentionedUserDTO(id="", type=""),
NoteMentionedUserDTO(id="", type=""),
// etc.
)
)
).execute()
Hope this helps!