0

I need to be able to create a product and add it's levelwithskills (An array of objects which contains level name and array of skills) in a single request.

I have this schema:

input LevelData {
    name: String!
    skills: [SkillsData]!
}

input SkillsData {
    name: String!
    price: Int
    duration: Int
    stepbystep: String
    teamchallange: String
}

type Mutation {
    createProduct(productInputData: ProductInputData): String
}

input ProductInputData {
    type: String!
    passion: String!
    course: String!
    levelwithskills: [LevelData]
    skills: [String]
    startdate: String!
    enddate: String!
}

The query i'm trying to send

createProduct(productInputData: {
    passion: "Tester"
    course: "Java and BDD"
    skills: ["HTML/CSS/JS"]
    levelwithskills: [{
      name: "Beginner"
      skills: [{
        name: "HTML/CSS/JS"
      }]
    },
    {
      name: "Intermediate"
      skills: [{
        name: "HTML/CSS/JS"
      }]
    }]
    startdate: "2019-06-20T11:00:09.459Z"
    enddate: "2019-06-20T11:30:09.459Z"
    type: "privatelesson"
  })

But Graphql gives me an error that states:

Validation error of type WrongType: argument 'productInputData.levelwithskills[0]' with value 'ObjectValue{objectFields=[ObjectField{name='type', value=StringValue{value='privatelesson'}}, ObjectField{name='course', value=StringValue{value='Java and BDD'}}, ObjectField{name='passion', value=StringValue{value='Tester'}}, ObjectField{name='levelwithskills', value=ArrayValue{values=[EnumValue{name='object'}, EnumValue{name='Object'}]}}, ObjectField{name='skills', value=ArrayValue{values=[StringValue{value='HTML/CSS/JS'}]}}, ObjectField{name='startdate', value=StringValue{value='2019-06-19T16:00:00.000Z'}}, ObjectField{name='enddate', value=StringValue{value='2019-06-19T16:45:00.000Z'}}' must be an object type @ 'createProduct'
Nikhil Shrestha
  • 1,210
  • 1
  • 11
  • 18

1 Answers1

0

In your schema, you have a single mutation field called createProduct, but you said the query you're trying to send is called createProductPayment, so my guess it's oging down a different part of your schema. Is there more to your schema you can share with us?

Aaron_H
  • 1,623
  • 1
  • 12
  • 26