Comments (9)
Closing this because we moved the server and the issue no longer exists here.
from graphql-tools.
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.
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.
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.
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.
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.
This works great for me, thanks. Would you like this to be a config option? Naming suggestions?
from graphql-tools.
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.
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)
- SSE stream breaks when response data is large HOT 2
- Allow for empty objects in mock store HOT 2
- Apollo Subgraph entities are not resolved when using `wrapSchema` HOT 13
- getLoader in batch-delegate uses a non-unique cacheKey HOT 1
- graphql-ws executor does not resolve `connectionParams`
- Project Roadmap HOT 2
- Drop dependency on fast-url-parser HOT 2
- DEBUG=1 results in console.time() warnings
- @graphql-tools/mock does not work with Vitest HOT 5
- Deterministic (seeded) enum values
- Stitching: object field is null when all selections are delegated
- Http Executor encodes headers into query parameters which can leak Authorization headers
- Ability to get names of all the stitched queries in a middleware
- requireResolversToMatchSchema: 'warn' throws an error
- Support .astro file loading on graphql-tag-pluck HOT 1
- Troubles with connectionParams on subscriptions
- Adding content-type header is not supported when fetching schema
- Query does not provide a operation name as a property in the request body causing some server configurations to reject the request
- @graphql-tools/mock 9.0.1 causes panic: Internal errors HOT 2
- @graphql-tools/merge directive arguments compare should not require identical ordering HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-tools.