Skip to content

Instantly share code, notes, and snippets.

@bessey
Created December 23, 2016 05:15
Show Gist options
  • Save bessey/ce9e0451ce57bb25b5950b1d1f8198a1 to your computer and use it in GitHub Desktop.
Save bessey/ce9e0451ce57bb25b5950b1d1f8198a1 to your computer and use it in GitHub Desktop.
Mocked graphql schema, and the error it generates
Expected a value of type "Time" but received: 2016-12-23T05:04:10.611Z
const resolvers = {
Time: () => ({
__serialize: (val) => val,
__parseValue: (val) => val,
__parseLiteral: (val) => val
})
}
const mocks = {
Time: () => new Date().toISOString()
}
const schema = makeExecutableSchema({ typeDefs: schemaFile, resolvers: resolvers })
addMockFunctionsToSchema({ schema, mocks })
const client new ApolloClient({
networkInterface: {
query: function (request) {
return execute(
schema, request.query, {}, {}, request.variables, request.operationName
).then((result) => {
console.log(result.errors)
return result
})
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment