Comments (6)
@bsr203 Looking just at the query and response it's really hard to tell. Can you show me the relevant part of your schema and how you're passing it to the server? Is node always a viewer? And is this using actual resolve functions, or are you using mocking?
from graphql-tools.
thanks for the quick response. I will try to get a reproducible case. Node is an interface with 9 implementations. I don't have any resolve/ custom mock function, but just the default mock by graphql-tools. Is there anything like sampling from 9 implementation? but anyway, I will try to make a reproducible case. thanks again.
from graphql-tools.
Okay, so this could be due to the mocking indeed, because if you don't have resolve functions and don't specify the mocks then it will randomly pick one of the implementing types for the interface. Since you only ask for a fragment on the Viewer type, the response will come back empty in 8 out of 9 cases, because Viewer is only one of the 9 types.
from graphql-tools.
so, is it feasible to identify the fragment type and mock appropriately by graphql-tools
, or it should be the responsibility of the user to provide a resolve function? Do you have any rough sketch or any example/test case to point to. thanks again.
from graphql-tools.
I think looking into fragments to decide what interface gets mocked would make things a bit more complicated, but it shouldn't be too hard to do. One thing to keep in mind however is that what you're getting right now is a completely valid GraphQL response, so your program should be able to deal with it.
If you want to mock only a certain type of the interface, one way to go about it would be to specify the node
mock and return an object with { typename: "Viewer"}
. I'm not 100% sure, but believe that would give you what you want.
You can find a test case in the test folder, just search for interface. The actual implementation is in mock.js
from graphql-tools.
thank you. I will close this now, as you said, it is a valid response. Will try out the options you suggested and get back with you. thanks again.
from graphql-tools.
Related Issues (20)
- 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
- load babel options in `graphql-tag-pluck`
- [mock] relayStylePaginationMock sometimes returns an incorrect value for hasNextPage
- Batch execution throws an error when Array.prototype has additional property
- Federation @join__field requires parameter handling improvement
- filterSchema argumentFilter provides incorrect typeName
- globalGqlIdentifierName is inconsistently forced lowercase so doesn't work with mixed case identifiers HOT 1
- makeExecutableSchema fails if typeDefs includes a directive named toString
- Vite plugin a la jest-transform for GraphQL?
- Nested fields of @computed parent are not resolved HOT 1
- Handle thrown values correctly even if they are not instances of `Error`.
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.