Prisma 1 Forum

Variables $ got invalid value (Creating mutation with nested array of objects)

Hello EveryOne.
Really need some help here
I am trying to create new item but getting error “variables $ got invalid value”
here is my datamodel

type Item {
  id:           ID! @id
  title:        String!
  description:  String!       @default(value: "No Description Provided")
  image:        String        @default(value: "No Image Provided")
  largeImage:   String        @default(value: "No Image Provided")
  brand:        String!
  weight:       String!
  dimensions:   String!
  materials:    String!
  price:        Float!
  stock:        Int!          @default(value: 1)
  tags:         [Tags]        @relation(name: INLINE)
  user:         User          @relation(link: INLINE)
  createdAt:    DateTime!     @createdAt
  updatedAt:    DateTime!     @updatedAt
}

type Tags {
  id:         ID! @id
  text:       String!
  item:       [Item] 
}

and my Schema

createItem(
    title: String!
    description: String!
    image: String
    largeImage: String
    brand: String!
    weight: String!
    dimensions: String!
    materials: String!
    price: Int!
    stock: Int!
    tags: [ItemCreateWithoutTagsInput]! 
    
  ): Item!

Apollo Client

const CREATE_ITEM_MUTATION = gql`
  mutation CREATE_ITEM_MUTATION(
    $title: String!
    $dimensions: String!
    $description: String!
    $image: String
    $largeImage: String
    $brand: String!
    $weight: String!
    $materials: String!
    $price: Int!
    $stock: Int!
    $tags: [ItemCreateWithoutTagsInput]! 
  ) {
    createItem(
      title: $title
      dimensions: $dimensions
      description: $description
      image: $image
      largeImage: $largeImage
      brand: $brand
      weight: $weight
      materials: $materials
      price: $price
      stock: $stock
      tags: $tags
    ) {
      id
      title
    }
  }
`;

The data being sent

brand: "Brand"

description: "↵ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Obcaecati vero incidunt consequuntur nihil suscipit, fuga nesciunt ratione! Harum inventore dolores eos explicabo vero? Nisi dolor vel tenetur voluptatem tempora eveniet?"

dimensions: "Dimensions"

image: ""

materials: "Materials"

price: 900

stock: 100

tags: Array(2)

0: {id: "Pakistan", text: "Pakistan"}

1: {id: "America", text: "America"}

length: 2

__proto__: Array(0)

title: "Title"

weight: "Weight"

My tag is array of objects
I would really appreciate some help here

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.