Add imageAspectRatio to seeded Post

This commit is contained in:
mattwr18 2019-11-27 12:08:21 +01:00
parent 33fb439e18
commit 2332576e17
3 changed files with 32 additions and 2 deletions

View File

@ -45,4 +45,5 @@ module.exports = {
default: () => new Date().toISOString(), default: () => new Date().toISOString(),
}, },
language: { type: 'string', allow: [null] }, language: { type: 'string', allow: [null] },
imageAspectRatio: { type: 'float', default: 1.0 },
} }

View File

@ -19,6 +19,7 @@ export default function create() {
visibility: 'public', visibility: 'public',
deleted: false, deleted: false,
categoryIds: [], categoryIds: [],
imageAspectRatio: 1.0,
} }
args = { args = {
...defaults, ...defaults,

View File

@ -352,6 +352,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
language: sample(languages), language: sample(languages),
image: faker.image.unsplash.food(), image: faker.image.unsplash.food(),
categoryIds: ['cat16'], categoryIds: ['cat16'],
imageAspectRatio: 1.777,
}), }),
factory.create('Post', { factory.create('Post', {
author: bobDerBaumeister, author: bobDerBaumeister,
@ -359,24 +360,28 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
language: sample(languages), language: sample(languages),
image: faker.image.unsplash.technology(), image: faker.image.unsplash.technology(),
categoryIds: ['cat1'], categoryIds: ['cat1'],
imageAspectRatio: 0.2,
}), }),
factory.create('Post', { factory.create('Post', {
author: huey, author: huey,
id: 'p3', id: 'p3',
language: sample(languages), language: sample(languages),
categoryIds: ['cat3'], categoryIds: ['cat3'],
imageAspectRatio: 0.5,
}), }),
factory.create('Post', { factory.create('Post', {
author: dewey, author: dewey,
id: 'p4', id: 'p4',
language: sample(languages), language: sample(languages),
categoryIds: ['cat4'], categoryIds: ['cat4'],
imageAspectRatio: 0.75,
}), }),
factory.create('Post', { factory.create('Post', {
author: louie, author: louie,
id: 'p5', id: 'p5',
language: sample(languages), language: sample(languages),
categoryIds: ['cat5'], categoryIds: ['cat5'],
imageAspectRatio: 1,
}), }),
factory.create('Post', { factory.create('Post', {
authorId: 'u1', authorId: 'u1',
@ -384,17 +389,20 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
language: sample(languages), language: sample(languages),
image: faker.image.unsplash.buildings(), image: faker.image.unsplash.buildings(),
categoryIds: ['cat6'], categoryIds: ['cat6'],
imageAspectRatio: 0.35,
}), }),
factory.create('Post', { factory.create('Post', {
author: huey, author: huey,
id: 'p9', id: 'p9',
language: sample(languages), language: sample(languages),
categoryIds: ['cat9'], categoryIds: ['cat9'],
imageAspectRatio: 1.25,
}), }),
factory.create('Post', { factory.create('Post', {
author: dewey, author: dewey,
id: 'p10', id: 'p10',
categoryIds: ['cat10'], categoryIds: ['cat10'],
imageAspectRatio: 1.5,
}), }),
factory.create('Post', { factory.create('Post', {
author: louie, author: louie,
@ -402,12 +410,14 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
language: sample(languages), language: sample(languages),
image: faker.image.unsplash.people(), image: faker.image.unsplash.people(),
categoryIds: ['cat11'], categoryIds: ['cat11'],
imageAspectRatio: 0.333,
}), }),
factory.create('Post', { factory.create('Post', {
author: bobDerBaumeister, author: bobDerBaumeister,
id: 'p13', id: 'p13',
language: sample(languages), language: sample(languages),
categoryIds: ['cat13'], categoryIds: ['cat13'],
imageAspectRatio: 0.4,
}), }),
factory.create('Post', { factory.create('Post', {
author: jennyRostock, author: jennyRostock,
@ -415,12 +425,14 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
language: sample(languages), language: sample(languages),
image: faker.image.unsplash.objects(), image: faker.image.unsplash.objects(),
categoryIds: ['cat14'], categoryIds: ['cat14'],
imageAspectRatio: 0.5,
}), }),
factory.create('Post', { factory.create('Post', {
author: huey, author: huey,
id: 'p15', id: 'p15',
language: sample(languages), language: sample(languages),
categoryIds: ['cat15'], categoryIds: ['cat15'],
imageAspectRatio: 0.8,
}), }),
]) ])
@ -434,8 +446,20 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
const hashtagAndMention1 = const hashtagAndMention1 =
'The new physics of <a class="hashtag" data-hashtag-id="QuantenFlussTheorie" href="/?hashtag=QuantenFlussTheorie">#QuantenFlussTheorie</a> can explain <a class="hashtag" data-hashtag-id="QuantumGravity" href="/?hashtag=QuantumGravity">#QuantumGravity</a>! <a class="mention" data-mention-id="u1" href="/profile/u1">@peter-lustig</a> got that already. ;-)' 'The new physics of <a class="hashtag" data-hashtag-id="QuantenFlussTheorie" href="/?hashtag=QuantenFlussTheorie">#QuantenFlussTheorie</a> can explain <a class="hashtag" data-hashtag-id="QuantumGravity" href="/?hashtag=QuantumGravity">#QuantumGravity</a>! <a class="mention" data-mention-id="u1" href="/profile/u1">@peter-lustig</a> got that already. ;-)'
const createPostMutation = gql` const createPostMutation = gql`
mutation($id: ID, $title: String!, $content: String!, $categoryIds: [ID]) { mutation(
CreatePost(id: $id, title: $title, content: $content, categoryIds: $categoryIds) { $id: ID
$title: String!
$content: String!
$categoryIds: [ID]
$imageAspectRatio: Float
) {
CreatePost(
id: $id
title: $title
content: $content
categoryIds: $categoryIds
imageAspectRatio: $imageAspectRatio
) {
id id
} }
} }
@ -449,6 +473,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
title: `Nature Philosophy Yoga`, title: `Nature Philosophy Yoga`,
content: hashtag1, content: hashtag1,
categoryIds: ['cat2'], categoryIds: ['cat2'],
imageAspectRatio: 0.66,
}, },
}), }),
mutate({ mutate({
@ -458,6 +483,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
title: 'This is post #7', title: 'This is post #7',
content: `${mention1} ${faker.lorem.paragraph()}`, content: `${mention1} ${faker.lorem.paragraph()}`,
categoryIds: ['cat7'], categoryIds: ['cat7'],
imageAspectRatio: 1.66,
}, },
}), }),
mutate({ mutate({
@ -468,6 +494,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
title: `Quantum Flow Theory explains Quantum Gravity`, title: `Quantum Flow Theory explains Quantum Gravity`,
content: hashtagAndMention1, content: hashtagAndMention1,
categoryIds: ['cat8'], categoryIds: ['cat8'],
imageAspectRatio: 0.3,
}, },
}), }),
mutate({ mutate({
@ -477,6 +504,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
title: 'This is post #12', title: 'This is post #12',
content: `${mention2} ${faker.lorem.paragraph()}`, content: `${mention2} ${faker.lorem.paragraph()}`,
categoryIds: ['cat12'], categoryIds: ['cat12'],
imageAspectRatio: 1.5,
}, },
}), }),
]) ])