Skip to content

Instantly share code, notes, and snippets.

@eduardopc
Created December 10, 2020 03:52
Show Gist options
  • Save eduardopc/82d5539f8213e357be09c2d67bce7e00 to your computer and use it in GitHub Desktop.
Save eduardopc/82d5539f8213e357be09c2d67bce7e00 to your computer and use it in GitHub Desktop.
const animals = [
{
animal: 'dog',
emoji: '๐Ÿถ'
},
{
animal: 'cat',
emoji: '๐Ÿฑ'
},
{
animal: 'pig',
emoji: '๐Ÿท'
},
{
animal: 'cow',
emoji: '๐Ÿฎ'
},
{
animal: 'chicken',
emoji: '๐Ÿ”'
}];
export const typeDefs = `
type Animal {
animal: String
emoji: String
}
type Query {
whatsAnimal: Animal
}
`;
export const resolvers = {
Query: {
whatsAnimal: () => {
const idx = Math.floor(Math.random() * animals.length);
return animals[idx];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment