You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to run this query against the swapi demo server with apollo-client:
query MyQuery {
...TheFilms
...ThePeople
}
fragment TheFilms on Root {
allFilms {
films {
id
title
}
}
}
fragment ThePeople on Root {
allPeople {
people {
name
}
}
}
Intended outcome:
I expect apollo-client to return the same result as GraphiQL:
Here is a repo with code that reproduces the issue.
Here is the code to reproduce:
asyncfunctionmain(){constApolloClient=require("apollo-client").ApolloClient;constHttpLink=require("apollo-link-http").HttpLink;constInMemoryCache=require("apollo-cache-inmemory").InMemoryCache;constfetch=require("node-fetch");constgql=require("graphql-tag");constclient=newApolloClient({link: newHttpLink({uri: "http://graphql.org/swapi-graphql",fetch: fetch}),cache: newInMemoryCache()});constquery=gql` query MyQuery { ...TheFilms ...ThePeople } fragment TheFilms on Root { allFilms { films { id title } } } fragment ThePeople on Root { allPeople { people { name } } } `;constresult=awaitclient.query({ query });console.log("result",result);}main();
Version
apollo-client@2.0.4
The text was updated successfully, but these errors were encountered:
I found today that this only happens when you have a query operation that only has fragment spreads and nothing else. If I add something else, like a regular field, to the query operations selection set then it works and the spreads are also resolved.
For example this would work:
query MyQuery {
...TheFilms
...ThePeople
allPlanets {
totalCount
}
}
fragment TheFilms on Root {
allFilms {
films {
id
title
}
}
}
fragment ThePeople on Root {
allPeople {
people {
name
}
}
}
jonaskello
changed the title
Fails to return result when using fragment on root
Fails to return result when using only fragment spreads in query operation
Dec 14, 2017
Issue description
I'm trying to run this query against the swapi demo server with apollo-client:
Intended outcome:
I expect apollo-client to return the same result as GraphiQL:
Actual outcome:
apollo-client returns this:
How to reproduce the issue:
Here is a repo with code that reproduces the issue.
Here is the code to reproduce:
Version
The text was updated successfully, but these errors were encountered: