I am trying to start yoga server with mocks.
Just copy-pasting example from the docs doesn't work:
import { GraphQLServer, MockList } from 'graphql-yoga'
const typeDefs = `
type Query {
hello(name: String): String!
listOfStrings: [String]
}
`
const mocks = {
Query: () => ({
hello: () => 'Hello World',
listOfStrings: () => new MockList([2, 6]),
}),
}
const server = new GraphQLServer({ typeDefs, mocks })
server.start()
And got an Error: No schema defined, at /node_modules/graphql-yoga/src/index.ts
I had the same issue, when following the mocking example in the README.
@checkmatez @merelinguist I dont know if there is bug or feature, but you have to pass at least empty resolvers.
import { GraphQLServer, MockList } from 'graphql-yoga'
const typeDefs = `
type Query {
hello(name: String): String!
listOfStrings: [String]
}
`
const mocks = {
Query: () => ({
hello: () => 'Hello World',
listOfStrings: () => new MockList([2, 6]),
}),
}
const server = new GraphQLServer({ typeDefs, resolvers: () => true, mocks })
server.start()
@borisowsky Thanks! That works perfectly. ✨
Due to inactivity of this issue we have marked it stale. It will be closed if no further activity occurs.
Hey :wave:, It seems like this issue has been inactive for some time. In need for maintaining clear overview of the issues concerning the latest version of graphql-yoga we'll close it.
Feel free to reopen it at any time if you believe we should futher discuss its content. :slightly_smiling_face:
Most helpful comment
@checkmatez @merelinguist I dont know if there is bug or feature, but you have to pass at least empty resolvers.