Skip to content

Support fragments in GraphQL API queries #8717

@zahinafsar

Description

@zahinafsar

Using fragment in GraphQL

Returns

{
  "errors": [
    {
      "message": "Query should contain either measures, dimensions or timeDimensions with granularities in order to be valid",
      "locations": [
        {
          "line": 34,
          "column": 3
        }
      ],
      "path": [
        "cube"
      ]
    }
  ],
  "data": null
}

The Query

	fragment recoveredSalesStats on Result {
		orders {
			recovered_sales
			created_at @include(if: $charts) {
                            hour @include(if: $isHourly)
                            day @include(if: $isDaily)
                            week @include(if: $isWeekly)
                            month @include(if: $isMonthly)
                            year @include(if: $isYearly)
                        }
		}
	}
	
	query GetRecoveredSalesStats(
		$currDateRange: [String]
		$prevDateRange: [String]
		$brandId: String
		$workflowId: String
		$charts: Boolean = true
		$isHourly: Boolean = false
		$isDaily: Boolean = false
		$isWeekly: Boolean = false
		$isMonthly: Boolean = false
		$isYearly: Boolean = false
		$timezone: String
	) {
		cube(
			timezone: $timezone
			where: {
				workflows: { id: { equals: $workflowId } }
				brands: { id: { equals: $brandId } }
				orders: { created_at: { inDateRange: $currDateRange } }
			}
		) {
			...recoveredSalesStats
		}
		prev: cube(
			timezone: $timezone
			where: {
				workflows: { id: { equals: $workflowId } }
				brands: { id: { equals: $brandId } }
				orders: { created_at: { inDateRange: $prevDateRange } }
			}
		) {
			...recoveredSalesStats
		}
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    api:graphqlIssues related to GraphQL APIhelp wantedCommunity contributions are welcome.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions