Skip to content

Instantly share code, notes, and snippets.

@MichaelrMentele
Last active March 22, 2022 20:48
Show Gist options
  • Save MichaelrMentele/a55867f91d3639d933059711e99b0714 to your computer and use it in GitHub Desktop.
Save MichaelrMentele/a55867f91d3639d933059711e99b0714 to your computer and use it in GitHub Desktop.
// this works
import CommentForm from './CommentForm'
export const generated = () => {
mockGraphQLMutation('CreateCommentMutation', (variables, { ctx }) => {
const id = parseInt(Math.random() * 1000)
ctx.delay(1000)
return {
createComment: {
id,
name: variables.input.name,
body: variables.input.body,
createdAt: new Date().toISOString(),
},
}
})
return <CommentForm />
}
export default { title: 'Components/CommentForm' }
// this doesn't work
```
ref gql
const DELETE_VEHICLE_MUTATION = gql`
mutation DeleteVehicleMutation($id: Int!) {
deleteVehicle(id: $id) {
id
}
}
`
```
import Vehicles from './Vehicles'
const vehicles = [
{
id: 1,
make: 'Honda',
model: 'Civic',
createdAt: '2020-01-21T22:00:00.000Z',
updatedAt: '2020-01-21T22:00:00.000Z',
},
]
export const generated = () => {
mockGraphQLMutation('DeleteVehicleMutation', (variables, { ctx }) => {
const id = parseInt(Math.random() * 1000)
ctx.delay(1000)
return {
deleteVehicle: {
id: variables.id,
},
}
})
return <Vehicles vehicles={vehicles} />
}
export default { title: 'Components/Vehicles' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment