Last active
July 11, 2017 11:18
-
-
Save a7v8x/d9de2c04354f92f6b7ec505c99022910 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
import { | |
GraphQLList, | |
GraphQLNonNull, | |
} from 'graphql'; | |
import { | |
internet, | |
random, | |
} from 'faker'; | |
import { | |
UserType, | |
UserInputType, | |
} from './usersTypes'; | |
export const userQueries = { | |
users: { | |
type: new GraphQLList(UserType), | |
resolve: async () => { | |
const users = await new Promise(resolve => | |
setTimeout(() => | |
resolve(new Array(10).fill(undefined).map(() => ({ | |
id: random.uuid(), | |
email: internet.email(), | |
}))), 100), | |
); | |
return users; | |
}, | |
}, | |
}; | |
export const userMutations = { | |
createUser: { | |
type: UserType, | |
args: { | |
userPayload: { | |
type: new GraphQLNonNull(UserInputType), | |
}, | |
}, | |
resolve: async (rootValue, { userPayload }) => { | |
const result = await new Promise((resolve) => { | |
setTimeout(() => | |
resolve(Object.assign(userPayload, { | |
id: random.uuid(), | |
})), 100); | |
}); | |
return result; | |
}, | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment