Passing array of objects to the React typescript graphql mutation

I am trying to pass array of objects to the graphql mutation in react and typescript. My object contain one file insert by user.

const CREAT_SCOPES = gql` 
mutation uploadFiles( 
    $createBy: String!, 
    $file_name: String!, 
    $value: Float!, 
    $file: Upload! 
  ) 
  { uploadFiles
    (scopedetails:{ 
       createBy: $createBy, 
       file_name: $file_name, 
       value: $value, 
       file: $file }) }`;

For my mutation I need to pass an array of objects,

[{
createBy: $createBy
file_name: $file_name
value: $value,
file: $file},
{
createBy: $createBy
file_name: $file_name
value: $value,
file: $file
}]

I dont know how to change my mutation to accept array of objects.

mutation uploadFiles( 
    $createBy: String!, 
    $file_name: String!, 
    $value: Float!, 
    $file: Upload! 
  ) 

Can I accept array of objects in mutation. Please share a way of doing it.
I am using react with typescript and @apollo/client.
Thanks in advance.

Hi @buddhika :wave: welcome to the forum! A few questions then a suggestion:

For my mutation I need to pass an array of objects,

How is the uploadFiles mutation defined in the schema definition of your GraphQL server? I think this should be accessible through an introspection query.

But you should be able to use an Input type here:

input UploadFilesInput {
  createBy: String!
  file_name: String!
  value: Float!
  file: Upload!
}

mutation UploadFiles($scopedetails: [UploadFilesInput!]!) {
  uploadFiles(scopedetails: $scopedetails) {
    # etc.
  }
}

I hope that helps!