GraphQL API does not support fragments
- Dominant language
- Rust
- Stars
- 20.8k
- Forks
- 2.1k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 181
Description
**Describe the bug**
We would expect the GraphQL API to support GraphQL fragments, but all columns coming from GraphQL fragments show up as null.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to Cube Playground
2. Click on GraphiQL
3. Attempt a query with fragments:
```
fragment Fields on OrdersMembers {
count
totalAmount
toRemove
}
query FragmentQuery {
cube(
limit: 5000
timezone: "America/Los_Angeles"
) {
orders {
...Fields
timestamp {
hour
}
}
}
}
```
Note that all columns return null.
4. Attempt a non-fragment query:
```
query NonFragmentQuery {
cube(
limit: 5000
timezone: "America/Los_Angeles"
) {
orders {
count
totalAmount
toRemove
timestamp {
hour
}
}
}
}
```
Note that data returns as we would expect.
**Expected behavior**
Equivalent queries should return the exact same data.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Minimally reproducible Cube Schema**
In case your bug report is data modelling related please put your minimally reproducible Cube Schema here.
You can use selects without tables in order to achieve that as follows.
```javascript
cube(`Orders`, {
sql: `
select 1 as id, 100 as amount, 'new' status
UNION ALL
select 2 as id, 200 as amount, 'new' status
UNION ALL
select 3 as id, 300 as amount, 'processed' status
UNION ALL
select 4 as id, 500 as amount, 'processed' status
UNION ALL
select 5 as id, 600 as amount, 'shipped' status
`,
measures: {
count: {
type: `count`,
},
totalAmount: {
sql: `amount`,
type: `sum`,
},
toRemove: {
type: `count`,
},
},
dimensions: {
status: {
sql: `status`,
type: `string`,
},
},
});
```
**Version:**
0.34.50
**Additional context**
I'm not sure if reaching for something like [Postgraphile](https://www.graphile.org/postgraphile/) could help standardize the GraphQL implementation here (and be less work to maintain), food for thought.
Contributor guide
Assessment
This issue has not been assessed yet.