kachulio1 314dfcf413 Throw error if no categories on post creation
Co-authored-by: mattwr18 <mattwr18@gmail.com>
2019-08-15 17:55:02 +03:00

52 lines
1.1 KiB
JavaScript

import faker from 'faker'
import uuid from 'uuid/v4'
export default function(params) {
const {
id = uuid(),
slug = '',
title = faker.lorem.sentence(),
content = [
faker.lorem.sentence(),
faker.lorem.sentence(),
faker.lorem.sentence(),
faker.lorem.sentence(),
faker.lorem.sentence(),
].join('. '),
image = faker.image.unsplash.imageUrl(),
visibility = 'public',
deleted = false,
categoryIds,
} = params
return {
mutation: `
mutation(
$id: ID!
$slug: String
$title: String!
$content: String!
$image: String
$visibility: Visibility
$deleted: Boolean
$categoryIds: [ID]
) {
CreatePost(
id: $id
slug: $slug
title: $title
content: $content
image: $image
visibility: $visibility
deleted: $deleted
categoryIds: $categoryIds
) {
title
content
}
}
`,
variables: { id, slug, title, content, image, visibility, deleted, categoryIds },
}
}