Last active
March 22, 2022 20:48
-
-
Save MichaelrMentele/a55867f91d3639d933059711e99b0714 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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