Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL API does not support fragments #8274

Open
peterklingelhofer opened this issue May 17, 2024 · 1 comment
Open

GraphQL API does not support fragments #8274

peterklingelhofer opened this issue May 17, 2024 · 1 comment
Labels
api:graphql Issues related to GraphQL API enhancement New feature proposal help wanted Community contributions are welcome.

Comments

@peterklingelhofer
Copy link
Contributor

peterklingelhofer commented May 17, 2024

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.

  1. 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.

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 could help standardize the GraphQL implementation here (and be less work to maintain), food for thought.

@igorlukanin igorlukanin added enhancement New feature proposal help wanted Community contributions are welcome. api:graphql Issues related to GraphQL API labels May 20, 2024
Copy link

If you are interested in working on this issue, please go ahead and provide PR for that.
We'd be happy to review it and merge it.
If this is the first time you are contributing a Pull Request to Cube, please check our contribution guidelines.
You can also post any questions while contributing in the #contributors channel in the Cube Slack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api:graphql Issues related to GraphQL API enhancement New feature proposal help wanted Community contributions are welcome.
Projects
None yet
Development

No branches or pull requests

2 participants