Интересно, как можно применить mutation
, используя graphql-tag
во вложенных типах, потому что в призме я использую create
для назначения полей
my datamodel.graphql
type Item {
id: ID! @id @unique
title: String
description: String
price: Int
laptop: Laptop @relation(link: INLINE)
}
type Laptop {
id: ID! @id
brand: String
}
myschema.graphql
type Mutation {
createItem(
title: String
description: String
price: Int
laptop: LaptopCreateOneInput
): Item!
}
я пробовал это до сих пор, но это не сработало
const CREATE_ITEM_MUTATION = gql`
mutation CREATE_ITEM_MUTATION(
$title: String!
$description: String!
$price: Int!
$laptop: LaptopCreateOneInput
) {
createItem(
title: $title
description: $description
price: $price
laptop:$laptop
) {
id
}
}
`;
я могу применить мутацию в Graphql Playground, как это
mutation {
createItem(
title: "computer"
description: "some computer"
price: 1000
laptop: { create: { brand: "some brand" } }
) {
title
description
}
}