diff --git a/fixtures/hasura/chinook/metadata/models/Invoice.hml b/fixtures/hasura/chinook/metadata/models/Invoice.hml index 654de3b8..f48cdd1c 100644 --- a/fixtures/hasura/chinook/metadata/models/Invoice.hml +++ b/fixtures/hasura/chinook/metadata/models/Invoice.hml @@ -124,6 +124,21 @@ definition: graphql: typeName: InvoiceComparisonExp +--- +kind: AggregateExpression +version: v1 +definition: + name: InvoiceAggregateExp + operand: + object: + aggregatedType: Invoice + aggregatableFields: + - fieldName: total + aggregateExpression: DecimalAggregateExp + count: { enable: true } + graphql: + selectTypeName: InvoiceAggregateExp + --- kind: Model version: v1 @@ -133,6 +148,7 @@ definition: source: dataConnectorName: chinook collection: Invoice + aggregateExpression: InvoiceAggregateExp filterExpressionType: InvoiceComparisonExp orderableFields: - fieldName: id @@ -166,6 +182,10 @@ definition: orderByDirections: enableAll: true graphql: + aggregate: + queryRootField: + invoiceAggregate + filterInputTypeName: InvoiceFilterInput selectMany: queryRootField: invoice selectUniques: diff --git a/fixtures/hasura/chinook/metadata/models/InvoiceLine.hml b/fixtures/hasura/chinook/metadata/models/InvoiceLine.hml index fcf35656..223b5902 100644 --- a/fixtures/hasura/chinook/metadata/models/InvoiceLine.hml +++ b/fixtures/hasura/chinook/metadata/models/InvoiceLine.hml @@ -92,6 +92,23 @@ definition: graphql: typeName: InvoiceLineComparisonExp +--- +kind: AggregateExpression +version: v1 +definition: + name: InvoiceLineAggregateExp + operand: + object: + aggregatedType: InvoiceLine + aggregatableFields: + - fieldName: quantity + aggregateExpression: IntAggregateExp + - fieldName: unitPrice + aggregateExpression: DecimalAggregateExp + count: { enable: true } + graphql: + selectTypeName: InvoiceLineAggregateExp + --- kind: Model version: v1 @@ -101,6 +118,7 @@ definition: source: dataConnectorName: chinook collection: InvoiceLine + aggregateExpression: InvoiceLineAggregateExp filterExpressionType: InvoiceLineComparisonExp orderableFields: - fieldName: id @@ -122,6 +140,10 @@ definition: orderByDirections: enableAll: true graphql: + aggregate: + queryRootField: + invoiceLineAggregate + filterInputTypeName: InvoiceLineFilterInput selectMany: queryRootField: invoiceLine selectUniques: diff --git a/fixtures/hasura/chinook/metadata/models/Track.hml b/fixtures/hasura/chinook/metadata/models/Track.hml index c681ce5c..4755352d 100644 --- a/fixtures/hasura/chinook/metadata/models/Track.hml +++ b/fixtures/hasura/chinook/metadata/models/Track.hml @@ -130,6 +130,25 @@ definition: graphql: typeName: TrackComparisonExp +--- +kind: AggregateExpression +version: v1 +definition: + name: TrackAggregateExp + operand: + object: + aggregatedType: Track + aggregatableFields: + - fieldName: unitPrice + aggregateExpression: DecimalAggregateExp + - fieldName: bytes + aggregateExpression: IntAggregateExp + - fieldName: milliseconds + aggregateExpression: IntAggregateExp + count: { enable: true } + graphql: + selectTypeName: TrackAggregateExp + --- kind: Model version: v1 @@ -139,6 +158,7 @@ definition: source: dataConnectorName: chinook collection: Track + aggregateExpression: TrackAggregateExp filterExpressionType: TrackComparisonExp orderableFields: - fieldName: id @@ -172,6 +192,10 @@ definition: orderByDirections: enableAll: true graphql: + aggregate: + queryRootField: + trackAggregate + filterInputTypeName: TrackFilterInput selectMany: queryRootField: track selectUniques: diff --git a/fixtures/hasura/common/metadata/scalar-types/Date.hml b/fixtures/hasura/common/metadata/scalar-types/Date.hml index 56e6f057..62085c8c 100644 --- a/fixtures/hasura/common/metadata/scalar-types/Date.hml +++ b/fixtures/hasura/common/metadata/scalar-types/Date.hml @@ -69,3 +69,32 @@ definition: graphql: typeName: DateComparisonExp +--- +kind: AggregateExpression +version: v1 +definition: + name: DateAggregateExp + operand: + scalar: + aggregatedType: Date + aggregationFunctions: + - name: _max + returnType: Date + - name: _min + returnType: Date + dataConnectorAggregationFunctionMapping: + - dataConnectorName: chinook + dataConnectorScalarType: Date + functionMapping: + _max: { name: max } + _min: { name: min } + - dataConnectorName: sample_mflix + dataConnectorScalarType: Date + functionMapping: + _max: { name: max } + _min: { name: min } + count: { enable: true } + countDistinct: { enable: true } + graphql: + selectTypeName: DateAggregateExp + diff --git a/fixtures/hasura/common/metadata/scalar-types/Decimal.hml b/fixtures/hasura/common/metadata/scalar-types/Decimal.hml index f8a034a3..1b1eb061 100644 --- a/fixtures/hasura/common/metadata/scalar-types/Decimal.hml +++ b/fixtures/hasura/common/metadata/scalar-types/Decimal.hml @@ -68,3 +68,40 @@ definition: enable: true graphql: typeName: DecimalComparisonExp + +--- +kind: AggregateExpression +version: v1 +definition: + name: DecimalAggregateExp + operand: + scalar: + aggregatedType: Decimal + aggregationFunctions: + - name: _avg + returnType: Decimal + - name: _max + returnType: Decimal + - name: _min + returnType: Decimal + - name: _sum + returnType: Decimal + dataConnectorAggregationFunctionMapping: + - dataConnectorName: chinook + dataConnectorScalarType: Decimal + functionMapping: + _avg: { name: avg } + _max: { name: max } + _min: { name: min } + _sum: { name: sum } + - dataConnectorName: sample_mflix + dataConnectorScalarType: Decimal + functionMapping: + _avg: { name: avg } + _max: { name: max } + _min: { name: min } + _sum: { name: sum } + count: { enable: true } + countDistinct: { enable: true } + graphql: + selectTypeName: DecimalAggregateExp diff --git a/fixtures/hasura/common/metadata/scalar-types/Double.hml b/fixtures/hasura/common/metadata/scalar-types/Double.hml index ea7e305a..7d4af850 100644 --- a/fixtures/hasura/common/metadata/scalar-types/Double.hml +++ b/fixtures/hasura/common/metadata/scalar-types/Double.hml @@ -60,3 +60,40 @@ definition: enable: true graphql: typeName: DoubleComparisonExp + +--- +kind: AggregateExpression +version: v1 +definition: + name: FloatAggregateExp + operand: + scalar: + aggregatedType: Float + aggregationFunctions: + - name: _avg + returnType: Float + - name: _max + returnType: Float + - name: _min + returnType: Float + - name: _sum + returnType: Float + dataConnectorAggregationFunctionMapping: + - dataConnectorName: chinook + dataConnectorScalarType: Double + functionMapping: + _avg: { name: avg } + _max: { name: max } + _min: { name: min } + _sum: { name: sum } + - dataConnectorName: sample_mflix + dataConnectorScalarType: Double + functionMapping: + _avg: { name: avg } + _max: { name: max } + _min: { name: min } + _sum: { name: sum } + count: { enable: true } + countDistinct: { enable: true } + graphql: + selectTypeName: FloatAggregateExp diff --git a/fixtures/hasura/common/metadata/scalar-types/Int.hml b/fixtures/hasura/common/metadata/scalar-types/Int.hml index 0afb1b1e..d5d7b0bd 100644 --- a/fixtures/hasura/common/metadata/scalar-types/Int.hml +++ b/fixtures/hasura/common/metadata/scalar-types/Int.hml @@ -60,3 +60,40 @@ definition: enable: true graphql: typeName: IntComparisonExp + +--- +kind: AggregateExpression +version: v1 +definition: + name: IntAggregateExp + operand: + scalar: + aggregatedType: Int + aggregationFunctions: + - name: _avg + returnType: Int + - name: _max + returnType: Int + - name: _min + returnType: Int + - name: _sum + returnType: Int + dataConnectorAggregationFunctionMapping: + - dataConnectorName: chinook + dataConnectorScalarType: Int + functionMapping: + _avg: { name: avg } + _max: { name: max } + _min: { name: min } + _sum: { name: sum } + - dataConnectorName: sample_mflix + dataConnectorScalarType: Int + functionMapping: + _avg: { name: avg } + _max: { name: max } + _min: { name: min } + _sum: { name: sum } + count: { enable: true } + countDistinct: { enable: true } + graphql: + selectTypeName: IntAggregateExp diff --git a/fixtures/hasura/sample_mflix/metadata/models/Comments.hml b/fixtures/hasura/sample_mflix/metadata/models/Comments.hml index 9014c47c..f6bb1d91 100644 --- a/fixtures/hasura/sample_mflix/metadata/models/Comments.hml +++ b/fixtures/hasura/sample_mflix/metadata/models/Comments.hml @@ -100,6 +100,21 @@ definition: graphql: typeName: CommentsComparisonExp +--- +kind: AggregateExpression +version: v1 +definition: + name: CommentsAggregateExp + operand: + object: + aggregatedType: Comments + aggregatableFields: + - fieldName: date + aggregateExpression: DateAggregateExp + count: { enable: true } + graphql: + selectTypeName: CommentsAggregateExp + --- kind: Model version: v1 @@ -109,6 +124,7 @@ definition: source: dataConnectorName: sample_mflix collection: comments + aggregateExpression: CommentsAggregateExp filterExpressionType: CommentsComparisonExp orderableFields: - fieldName: id @@ -130,6 +146,9 @@ definition: orderByDirections: enableAll: true graphql: + aggregate: + queryRootField: commentsAggregate + filterInputTypeName: CommentsFilterInput selectMany: queryRootField: comments selectUniques: @@ -149,12 +168,12 @@ definition: filter: null - role: user select: - filter: + filter: relationship: name: user - predicate: + predicate: fieldComparison: field: id operator: _eq - value: + value: sessionVariable: x-hasura-user-id diff --git a/fixtures/hasura/sample_mflix/metadata/models/Movies.hml b/fixtures/hasura/sample_mflix/metadata/models/Movies.hml index bf25fadc..87479299 100644 --- a/fixtures/hasura/sample_mflix/metadata/models/Movies.hml +++ b/fixtures/hasura/sample_mflix/metadata/models/Movies.hml @@ -53,6 +53,23 @@ definition: graphql: typeName: MoviesAwardsComparisonExp +--- +kind: AggregateExpression +version: v1 +definition: + name: MoviesAwardsAggregateExp + operand: + object: + aggregatedType: MoviesAwards + aggregatableFields: + - fieldName: nominations + aggregateExpression: IntAggregateExp + - fieldName: wins + aggregateExpression: IntAggregateExp + count: { enable: true } + graphql: + selectTypeName: MoviesAwardsAggregateExp + --- kind: ObjectType version: v1 @@ -108,6 +125,23 @@ definition: graphql: typeName: MoviesImdbComparisonExp +--- +kind: AggregateExpression +version: v1 +definition: + name: MoviesImdbAggregateExp + operand: + object: + aggregatedType: MoviesImdb + aggregatableFields: + - fieldName: rating + aggregateExpression: FloatAggregateExp + - fieldName: votes + aggregateExpression: IntAggregateExp + count: { enable: true } + graphql: + selectTypeName: MoviesImdbAggregateExp + --- kind: ObjectType version: v1 @@ -163,6 +197,25 @@ definition: graphql: typeName: MoviesTomatoesCriticComparisonExp +--- +kind: AggregateExpression +version: v1 +definition: + name: MoviesTomatoesCriticAggregateExp + operand: + object: + aggregatedType: MoviesTomatoesCritic + aggregatableFields: + - fieldName: meter + aggregateExpression: IntAggregateExp + - fieldName: numReviews + aggregateExpression: IntAggregateExp + - fieldName: rating + aggregateExpression: FloatAggregateExp + count: { enable: true } + graphql: + selectTypeName: MoviesTomatoesCriticAggregateExp + --- kind: ObjectType version: v1 @@ -218,6 +271,25 @@ definition: graphql: typeName: MoviesTomatoesViewerComparisonExp +--- +kind: AggregateExpression +version: v1 +definition: + name: MoviesTomatoesViewerAggregateExp + operand: + object: + aggregatedType: MoviesTomatoesViewer + aggregatableFields: + - fieldName: meter + aggregateExpression: IntAggregateExp + - fieldName: numReviews + aggregateExpression: IntAggregateExp + - fieldName: rating + aggregateExpression: FloatAggregateExp + count: { enable: true } + graphql: + selectTypeName: MoviesTomatoesViewerAggregateExp + --- kind: ObjectType version: v1 @@ -235,7 +307,7 @@ definition: - name: fresh type: Int - name: lastUpdated - type: String! + type: Date! - name: production type: String - name: rotten @@ -291,7 +363,7 @@ definition: - fieldName: fresh booleanExpressionType: IntComparisonExp - fieldName: lastUpdated - booleanExpressionType: StringComparisonExp + booleanExpressionType: DateComparisonExp - fieldName: production booleanExpressionType: StringComparisonExp - fieldName: rotten @@ -308,6 +380,31 @@ definition: graphql: typeName: MoviesTomatoesComparisonExp +--- +kind: AggregateExpression +version: v1 +definition: + name: MoviesTomatoesAggregateExp + operand: + object: + aggregatedType: MoviesTomatoes + aggregatableFields: + - fieldName: critic + aggregateExpression: MoviesTomatoesCriticAggregateExp + - fieldName: dvd + aggregateExpression: DateAggregateExp + - fieldName: fresh + aggregateExpression: IntAggregateExp + - fieldName: lastUpdated + aggregateExpression: DateAggregateExp + - fieldName: rotten + aggregateExpression: IntAggregateExp + - fieldName: viewer + aggregateExpression: MoviesTomatoesViewerAggregateExp + count: { enable: true } + graphql: + selectTypeName: MoviesTomatoesAggregateExp + --- kind: ObjectType version: v1 @@ -333,7 +430,7 @@ definition: - name: languages type: "[String!]" - name: lastupdated - type: Date! + type: String! - name: metacritic type: Int - name: numMflixComments @@ -482,7 +579,7 @@ definition: - fieldName: imdb booleanExpressionType: MoviesImdbComparisonExp - fieldName: lastupdated - booleanExpressionType: DateComparisonExp + booleanExpressionType: StringComparisonExp - fieldName: metacritic booleanExpressionType: IntComparisonExp - fieldName: numMflixComments @@ -515,6 +612,37 @@ definition: graphql: typeName: MoviesComparisonExp +--- +kind: AggregateExpression +version: v1 +definition: + name: MoviesAggregateExp + operand: + object: + aggregatedType: Movies + aggregatableFields: + # TODO: This requires updating the connector to support nested field + # aggregates + # - fieldName: awards + # aggregateExpression: MoviesAwardsAggregateExp + # - fieldName: imdb + # aggregateExpression: MoviesImdbAggregateExp + - fieldName: metacritic + aggregateExpression: IntAggregateExp + - fieldName: numMflixComments + aggregateExpression: IntAggregateExp + - fieldName: released + aggregateExpression: DateAggregateExp + - fieldName: runtime + aggregateExpression: IntAggregateExp + # - fieldName: tomatoes + # aggregateExpression: MoviesTomatoesAggregateExp + - fieldName: year + aggregateExpression: IntAggregateExp + count: { enable: true } + graphql: + selectTypeName: MoviesAggregateExp + --- kind: Model version: v1 @@ -524,6 +652,7 @@ definition: source: dataConnectorName: sample_mflix collection: movies + aggregateExpression: MoviesAggregateExp filterExpressionType: MoviesComparisonExp orderableFields: - fieldName: id @@ -593,6 +722,9 @@ definition: orderByDirections: enableAll: true graphql: + aggregate: + queryRootField: moviesAggregate + filterInputTypeName: MoviesFilterInput selectMany: queryRootField: movies selectUniques: @@ -610,4 +742,3 @@ definition: - role: admin select: filter: null - diff --git a/fixtures/hasura/sample_mflix/metadata/sample_mflix.hml b/fixtures/hasura/sample_mflix/metadata/sample_mflix.hml index 66d3e245..e552ce2f 100644 --- a/fixtures/hasura/sample_mflix/metadata/sample_mflix.hml +++ b/fixtures/hasura/sample_mflix/metadata/sample_mflix.hml @@ -964,7 +964,7 @@ definition: name: String procedures: [] capabilities: - version: 0.1.4 + version: 0.1.5 capabilities: query: aggregates: {}