GithubHelp home page GithubHelp logo

Comments (9)

helfer avatar helfer commented on April 30, 2024 1

Closing this because we moved the server and the issue no longer exists here.

from graphql-tools.

rdrey avatar rdrey commented on April 30, 2024

It would be great if resolvers and mocks can be mixed.

I've written a pretty large schema, and tested it with mocks. It would be great if I could now start to add resolvers and any broken fields keep returning mocked values. (With warnings / errors in the console or graphQL output.)

from graphql-tools.

helfer avatar helfer commented on April 30, 2024

Can you elaborate a bit? What do you mean by broken fields returning mocked values? Are those fields with a resolver that returns undefined, or fields without a resolver at all? I think the latter would be useful, but the former sounds like a recipe for trouble.

from graphql-tools.

rdrey avatar rdrey commented on April 30, 2024

The latter. I actually just saw this commit e83226a and I'm wondering if I just need to update my graphql-tools.

from graphql-tools.

helfer avatar helfer commented on April 30, 2024

That PR was actually just fixing another issue, which is to apply the resolvers before the mocks, to make sure the mocking of union types works (union types need the __resolveType function, which is not a resolver, but still has to be provided in the resolvers argument to apolloServer)

from graphql-tools.

helfer avatar helfer commented on April 30, 2024

I think the easiest way to get this to work is for apolloServer to pass preserveResolvers = true to addMockFunctionsToSchema inside apolloServer.js

I'd be open to a PR in that direction, if you'd like to see that feature implemented.

from graphql-tools.

rdrey avatar rdrey commented on April 30, 2024

This works great for me, thanks. Would you like this to be a config option? Naming suggestions?

from graphql-tools.

rdrey avatar rdrey commented on April 30, 2024

I think mixing mocks and resolvers kind of implies that this is what I want to do, so I'm inclined to just leave this turned on by default.

from graphql-tools.

helfer avatar helfer commented on April 30, 2024

I think rather than making it an option (and adding more arguments to the server), I would just turn it on by default like you suggested.

I just moved all the apolloServer code to apollo-server, so can you make your PR against the apollo-server repo? It would be a one-line change here, I think. Make sure to also add a test: https://github.com/apollostack/apollo-server/blob/2a4a41982d66d4a8502f2cff6a07018a9df8f1c4/src/apolloServer.js#L87

from graphql-tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.