Nested fragment results arent't merged into a query result
See original GitHub issueWhen a fragment selects nested fields and the original query also selects fields on that type, the fields from the fragment are left out and only the ones from the query are in the result.
Intended outcome:
The results from the nested fields of the fragment should be merged into the complete result.
Actual outcome:
The nested fields are left out.
How to reproduce the issue:
Here’s a query that can be run in Githunts’ GraphiQL. Notice that login
as well as avatar_url
is available in the result.
When the same query is run with apollo-client, only avatar_url
is available in the result.
Here’s a node script that shows the issue:
require('isomorphic-fetch');
const {default: ApolloClient, createNetworkInterface} = require('apollo-client');
const gql = require('graphql-tag').default;
const client = new ApolloClient({
networkInterface: createNetworkInterface({uri: 'http://www.githunt.com/graphql'})
});
const query = gql`
fragment RepositoryData on Repository {
owner {
login
}
}
{
feed(type: NEW, limit: 5) {
repository {
...RepositoryData
name
owner {
avatar_url
}
}
}
}
`;
const promise = client.query({query}).then(({data}) => {
console.log(JSON.stringify(data));
}, e => {
console.error(res);
});
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Relay: How to merge instead of override queries in nested ...
The problem is, that both App and UserList have defined fragements and it seems that only the query of UserList is send. Fragment...
Read more >Customizing the behavior of cached fields - Apollo GraphQL
You can use a merge function to intelligently combine nested objects that are not normalized in your cache, assuming those objects are nested...
Read more >com.fulcrologic.fulcro.algorithms.merge - cljdoc
Calculates the query that can be used to pull (or merge) a component with an ident to/from a normalized app database. Requires a...
Read more >Postgres: Sort query results | Hasura GraphQL Docs
Sort query results on Postgres in Hasura. ... The argument can be used to sort nested objects too. The sort order (ascending vs....
Read more >Nested fragments not being retained in support library v4 rev ...
Nested fragments do get retained on configuration changes (as expected) when reverting back to rev 19.1.0. Relevant sample code attached to reproduce the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
if you change
to read like this:
it works. This also works for as many fragments in any order, so it seems for now it’s best to always put them last.
Note that this issue is now fixed as of
graphql-anywhere
3.1.0