question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to start server with mocks

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

4reactions
nikitowskycommented, May 28, 2018

@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()
0reactions
stale[bot]commented, Nov 30, 2018

Hey 👋, 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. 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

mock server failing to start · Issue #2 · pact-foundation/grunt-pact
I've been trying to follow along with your progress, but I'm having trouble getting things to execute successfully with the latest master.
Read more >
Running MockServer
To run MockServer in Kubernetes the easiest way is to use the existing MockServer helm chart. This is available by using www.mock-server.com as...
Read more >
While running a MOCK API server in Node.js, getting an error ...
I am getting "CANNOT GET/" error message while running a MOCK API server opening my localhost on port 3000 via my browser ...
Read more >
mockserver-node | Yarn - Package Manager
Node module and grunt plugin to start and stop MockServer and MockServer proxy. Build status Dependency Status devDependency Status.
Read more >
Requests to my mock servers aren't returning the expected ...
The path URL is incorrect. Make sure the path in the request URL matches with one of the saved examples for the mock...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found