Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Check List
Summary
Adds
titleandshortTitlemetadata to GraphQL API responses, enabling clients to display human-readable labels without requiring separate/v1/metaREST API calls.Motivation
Currently, the GraphQL API only returns technical field names (e.g.,
Orders.count,Users.city) without their human-readable titles. Clients building dynamic UIs need to make additional REST API calls to/v1/metato fetch this metadata, requiring:This change brings the GraphQL API to feature parity with the REST API by including title information directly in query responses.
Changes
Schema Changes
Added three new GraphQL types:
Implementation
Modified Files:
Key Changes:
Response Format Changes
Before
{ "data": { "cube": [{ "orders": { "count": 150, "status": "completed", "createdAt": { "day": "2024-01-15T00:00:00.000Z" } } }] } }After
{ "data": { "cube": [{ "orders": { "count": { "value": 150, "title": "Orders Count", "shortTitle": "Count" }, "status": { "value": "completed", "title": "Orders Status", "shortTitle": "Status" }, "createdAt": { "day": "2024-01-15T00:00:00.000Z", "title": "Orders Created At", "shortTitle": "Created At" } } }] } }Example Query
Response now includes value, title, and shortTitle for each field, enabling self-documenting UIs.
Benefits
Testing
Added test case should return titles with scalar values that verifies:
Run tests:
cd packages/cubejs-api-gateway
yarn test graphql.test.ts --testNamePattern="should return titles"
Breaking Changes
Migration Guide
Clients will need to update their response handling:
Before:
const count = response.data.cube[0].orders.count;
// count = 150
After:
const count = response.data.cube[0].orders.count.value;
const title = response.data.cube[0].orders.count.title;
// count = 150
// title = "Orders Count"