Variable X got invalid value. Field “0” is not defined by type


#1

Hi, I’ve got this error but I don’t find what’s causing it, the message is a bit confusing. Thank you in advance for your help.

Message: Variable "$activities" got invalid value 
[{"activityType":"DELIVER","description":"Test description","files":
[{"url":"https://example.com/1566512642562-sample.pdf","__typename":"File"},
{"url":"https://example.com/1566512690865-demo.docx","__typename":"File"},
{"url":"https://example.com/1566512697222-sample.xml","__typename":"File"}],
"hasFiles":false,"name":"New Activity","objectiveName":"New objective",
"batchName":"New batch","batchStartDate":"2019-08-19T00:00:00.000Z",
"batchFinishDate":"2019-08-22T00:00:00.000Z"}]; 
Field "0" is not defined by type FileCreateManyInput at 
value[0].files., Location: [object Object], Path: undefined

Here are the related schema entries:

type Mutation {
  updateBatch(data: BatchUpdateInput!, where: BatchWhereUniqueInput!): Batch
}

input BatchUpdateInput {
  name: String
  batchID: String
  startDate: DateTime
  finishDate: DateTime
  description: String
  objectives: BatchObjectiveUpdateManyInput
  odes: ODEUpdateManyWithoutBatchesInput
  coordinator: UserUpdateOneRequiredWithoutBatchesInput
  program: ProgramUpdateOneRequiredWithoutBatchesInput
}

input BatchObjectiveUpdateManyInput {
  create: [BatchObjectiveCreateInput!]
  update: [BatchObjectiveUpdateWithWhereUniqueNestedInput!]
  upsert: [BatchObjectiveUpsertWithWhereUniqueNestedInput!]
  delete: [BatchObjectiveWhereUniqueInput!]
  connect: [BatchObjectiveWhereUniqueInput!]
  set: [BatchObjectiveWhereUniqueInput!]
  disconnect: [BatchObjectiveWhereUniqueInput!]
  deleteMany: [BatchObjectiveScalarWhereInput!]
  updateMany: [BatchObjectiveUpdateManyWithWhereNestedInput!]
}

input BatchObjectiveCreateInput {
  name: String!
  description: String!
  type: ObjectiveType!
  status: BatchObjectiveStatus!
  startDate: DateTime
  finishDate: DateTime
  activities: ActivityCreateManyInput
}

input ActivityCreateManyInput {
  create: [ActivityCreateInput!]
  connect: [ActivityWhereUniqueInput!]
}

input ActivityWhereUniqueInput {
  id: ID
}

input ActivityCreateInput {
  name: String!
  description: String!
  activityType: ActivityType!
  files: FileCreateManyInput
  hasFiles: Boolean
}

input FileCreateManyInput {
  create: [FileCreateInput!]
  connect: [FileWhereUniqueInput!]
}

input FileCreateInput {
  url: String!
  type: String!
}

input FileWhereUniqueInput {
  id: ID
}

Here’s the mutation:

mutation($type:ObjectiveType!, $activities: [ActivityCreateInput!]) {
  updateBatch(where:{id:"exampleid"} data: {
    objectives:{
      create:{
        name: "example"
        type: $type
        description:"example"
        status: ACTIVE
        activities:{
          create: $activities
        }
      }
    }
  }){id}                   
}

I tried solutions posted here but don’t work: