Commit Graph

367 Commits

Author SHA1 Message Date
Daniel Harvey
247eebb118 Remove logging error (#708)
Ahem.

V3_GIT_ORIGIN_REV_ID: ccb290c8c3fc6d68ed0485218185214674da9b3e
2024-06-12 09:26:04 +00:00
Daniel Chambers
1c5008df7c Aggregates Root Field - Part 3: GraphQL API (#685)
This is Part 3 in a stacked PR set that delivers aggregate root field
support.
* Part 1: OpenDD: https://github.com/hasura/v3-engine/pull/683
* Part 2: Metadata Resolve: https://github.com/hasura/v3-engine/pull/684

JIRA: [V3ENGINE-159](https://hasurahq.atlassian.net/browse/V3ENGINE-159)

## Description
This PR implements the GraphQL API for aggregate root fields. The
GraphQL schema matches the design in the [Aggregate and Grouping
RFC](https://github.com/hasura/v3-engine/blob/main/rfcs/aggregations.md#aggregations-walkthrough).

### Schema Generation
The main new part of the GraphQL schema generation can be found in
`crates/schema/src/aggregates.rs`. This is where we generate the new
aggregate selection types. However, the root field generation can be
found in `crates/schema/src/query_root/select_aggregate.rs`.

The new `filter_input` type generation lives in
`crates/schema/src/model_filter_input.rs`. As this type effectively
encapsulates the existing field arguments used on the Select Many root
field, the code to generate them has moved into `model_filter_input.rs`
and `select_many.rs` simply reuses the functionality from there (without
actually using the filter input type!).

### IR
The main aggregates IR generation for the aggregate root field happens
in `crates/execute/src/ir/query_root/select_aggregate.rs`. It reads all
the input arguments to the root field and then kicks the selection logic
over to `model_aggregate_selection_ir` from
`crates/execute/src/ir/model_selection.rs`.

`crates/execute/src/ir/model_selection.rs` has received some refactoring
to facilitate that new `model_aggregate_selection_ir` function; it
mostly shares functionality with the existing `model_selection_ir`,
except instead of creating fields IR, it creates aggregates IR instead.
The actual reading of the aggregate selection happens in
`crates/execute/src/ir/aggregates.rs`.

The aggregates selection IR captures the nested JSON structure of the
aggregate selection, because NDC does not return aggregates in the same
nested JSON structure as the GraphQL request. NDC takes a flat list of
aggregate operations to run. This captured nested JSON structure is used
during response rewriting to convert NDC's flat list into the nested
structure that matches the GraphQL request.

The aggregate selection IR is placed onto `ModelSelection` alongside the
existing fields IR. Since both fields and aggregates can be put into the
one NDC request (even though they are not right now), this made sense.
They both translate onto one NDC `Query`. This necessitated making the
field selection optional on the `ModelSelection`
(`ModelSelection.selection`), since aggregate requests currently don't
use them.

### Planning
`crates/execute/src/plan/model_selection.rs` takes care of mapping the
aggregates into the NDC request from the generated IR.

There has been a new `ProcessResponseAs` variant added in
`crates/execute/src/plan.rs` to capture how to read and reshape an NDC
aggregates response. This is handled in
`crates/execute/src/process_response.rs` where the captured JSON
structure in the IR is used to restore NDC's flat aggregates list into
the required nested JSON output structure.

### Testing
The Custom Connector has been updated with functionality to allow
aggregates over nested object fields
(`crates/custom-connector/src/query.rs`).

New execution and introspection tests have been added to
`crates/engine/tests/execute/aggregates/` to test aggregates against
Postgres and the Custom Connector.

[V3ENGINE-159]:
https://hasurahq.atlassian.net/browse/V3ENGINE-159?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

V3_GIT_ORIGIN_REV_ID: ff47f13eaca70d10de21e102a6667110f8f8af40
2024-06-12 09:02:12 +00:00
Daniel Chambers
81ac867d16 Aggregates Root Field - Part 2: Metadata Resolve (#684)
This is Part 2 in a stacked PR set that delivers aggregate root field
support.
* Part 1: OpenDD: https://github.com/hasura/v3-engine/pull/683
* Part 3: GraphQL API: https://github.com/hasura/v3-engine/pull/685

JIRA: [V3ENGINE-159](https://hasurahq.atlassian.net/browse/V3ENGINE-159)

## Description
This PR implements the metadata resolve phase of the engine and adds
support for resolving `AggregateExpression`s and validates their use
when linked to a `Model`.

The bulk of the changes can be found in:
* `crates/metadata-resolve/src/stages/aggregates/*` - This is where the
`AggregateExpression`s are resolved
* `crates/metadata-resolve/src/stages/models/mod.rs` - This is where we
validate the `AggregateExpression` specified for use in the model is
actually compatible with the model and its data connector

The `ndc-spec` version used has been lifted to the latest version that
adds support for aggregates over nested objects
(https://github.com/hasura/ndc-spec/pull/144). This necessitated changes
in the Custom Connector, but actual functionality to implement
aggregation over nested objects is implemented in Part 3.

There are also some changes in
`crates/metadata-resolve/src/types/subgraph.rs` where the `Display`
trait for the various `Qualified<T>`, `QualifiedTypeReference`, etc
types has been reworked so that they print more cleanly, with the
subgraph being put outside the type syntax, and array types getting
formatted correctly. For example, previous an array of Varchars would
have printed as `Varchar (in subgraph default)!`, now it properly
formats as `[Varchar!]! (in subgraph default)`.
This was necessary to make useful error messages using these types.

A tonne of tests have been added in
`crates/engine/tests/validate_metadata_artifacts/aggregate_expressions`
to test every error condition of the metadata resolve process.

[V3ENGINE-159]:
https://hasurahq.atlassian.net/browse/V3ENGINE-159?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

V3_GIT_ORIGIN_REV_ID: ffd859127a3f1560707f06ef01906c9d1b183d31
2024-06-12 08:30:25 +00:00
Daniel Chambers
e07197e1be Aggregates Root Field - Part 1: OpenDD (#683)
This is Part 1 in a stacked PR set that delivers aggregate root field
support.
* Part 2: Metadata Resolve: https://github.com/hasura/v3-engine/pull/684
* Part 3: GraphQL API: https://github.com/hasura/v3-engine/pull/685

JIRA: [V3ENGINE-159](https://hasurahq.atlassian.net/browse/V3ENGINE-159)

## Description
This PR is the first cut in implementing aggregates functionality for
v3, as defined in the [Aggregates and Grouping
RFC](https://github.com/hasura/v3-engine/blob/main/rfcs/aggregations.md).

This PR modifies the Open DD schema and adds the `AggregateExpression`
metadata object. It also modifies the `Model` and `GraphqlConfig` types
and adds new fields that are required to link in aggregates
functionality. For more information, please see the below RFC links.

This PR implements only the minimum properties required to get a
aggregates root fields in the GraphQL API. There is more defined in the
RFC that will be implemented in later iterations.

RFC links:
*
[AggregateExpression](https://github.com/hasura/v3-engine/blob/main/rfcs/aggregations.md#aggregateexpression-new)
*
[Model](https://github.com/hasura/v3-engine/blob/main/rfcs/aggregations.md#model--object-type)
*
[GraphqlConfig](https://github.com/hasura/v3-engine/blob/main/rfcs/aggregations.md#graphql-config)

## Changelog

### Product

_(Select all products this will be available in)_

- [x] community-edition
- [x] cloud
<!-- product : end : DO NOT REMOVE -->

### Type

- [ ] highlight
- [x] enhancement
- [ ] bugfix
- [ ] behaviour-change
- [ ] performance-enhancement
- [ ] security-fix
<!-- type : end : DO NOT REMOVE -->

### Changelog entry

Support for aggregate GraphQL root fields via the new
AggregateExpression OpenDD type and its use on the Model type

<!-- changelog-entry : end : DO NOT REMOVE -->

<!-- changelog : end : DO NOT REMOVE -->

[V3ENGINE-159]:
https://hasurahq.atlassian.net/browse/V3ENGINE-159?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

V3_GIT_ORIGIN_REV_ID: 6969ee73036a011e3026b58545c0286a65749067
2024-06-12 08:12:33 +00:00
Rakesh Emmadi
87d6e2a9b6 refactor IR types and related code (#704)
This is a no-op refactor of IR related types. Introducing a new concrete
`IR` enum with `Mutation` and `Query` variants, where each contains a
map of root fields.

V3_GIT_ORIGIN_REV_ID: 76a197f5cf1efb34a8493c2b3356bea2bc2feb3c
2024-06-12 04:28:28 +00:00
paritosh-08
9f3b8370c1 make FieldMapping enum again (#705)
<!-- Thank you for submitting this PR! :) -->

## Description

<!--
  Questions to consider answering:
  1. What user-facing changes are being made?
2. What are issues related to this PR? (Consider adding `(close
#<issue-no>)` to the PR title)
  3. What is the conceptual design behind this PR?
  4. How can this PR be tested/verified?
  5. Does the PR have limitations?
  6. Does the PR introduce breaking changes?
-->

This PR reverts the changes to `FieldMapping` and introduces the
`argument_mapping` in `ColumnMapping` instead.

V3_GIT_ORIGIN_REV_ID: badca2416b1a1b82d1a596aa60bf7a39b3b6152a
2024-06-12 02:16:36 +00:00
Philip Lykke Carlsen
b3641238a9 Simplify namespaced AllowAll (#702)
<!-- Thank you for submitting this PR! :) -->

## Description

It turns out that every usage of `Builder::allow_all_namespaced`
concerned itself with either introspection nodes or (in the GDS case)
`None`.

Combined with the fact that both the SDL and GDS implementations of
`SchemaContext::introspection_namespace_node` were trivial, the
`NamespacedNodeInfo` contained in
`Namespaced::AllowAll(S::NamespacedNodeInfo)` is always functionally
meaningless.

This PR removes the `NamespacedNodeInfo` from `Namespaced::AllowAll` as
well as `SchemaContext::introspection_namespace_node`, thus simplifying
the implementation.

<!--
  Questions to consider answering:
  1. What user-facing changes are being made?
2. What are issues related to this PR? (Consider adding `(close
#<issue-no>)` to the PR title)
  3. What is the conceptual design behind this PR?
  4. How can this PR be tested/verified?
  5. Does the PR have limitations?
  6. Does the PR introduce breaking changes?
-->

## Changelog

- Add a changelog entry (in the "Changelog entry" section below) if the
changes
  in this PR have any user-facing impact. See
[changelog
guide](https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide).
- If no changelog is required ignore/remove this section and add a
  `no-changelog-required` label to the PR.

### Product

_(Select all products this will be available in)_

- [ ] community-edition
- [ ] cloud
<!-- product : end : DO NOT REMOVE -->

### Type

<!-- See changelog structure:
https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide#structure-of-our-changelog
-->

_(Select only one. In case of multiple, choose the most appropriate)_

- [ ] highlight
- [ ] enhancement
- [ ] bugfix
- [ ] behaviour-change
- [ ] performance-enhancement
- [ ] security-fix
<!-- type : end : DO NOT REMOVE -->

### Changelog entry

<!--
  - Add a user understandable changelog entry
- Include all details needed to understand the change. Try including
links to docs or issues if relevant
  - For Highlights start with a H4 heading (#### <entry title>)
  - Get the changelog entry reviewed by your team
-->

_Replace with changelog entry_

<!-- changelog-entry : end : DO NOT REMOVE -->

<!-- changelog : end : DO NOT REMOVE -->

V3_GIT_ORIGIN_REV_ID: 1525905488203ff07182aa700c9fff26512743ab
2024-06-11 17:08:41 +00:00
paritosh-08
a3ea579006 add field arguments in open dd metadata (#694)
<!-- Thank you for submitting this PR! :) -->

## Description

<!--
  Questions to consider answering:
  1. What user-facing changes are being made?
2. What are issues related to this PR? (Consider adding `(close
#<issue-no>)` to the PR title)
  3. What is the conceptual design behind this PR?
  4. How can this PR be tested/verified?
  5. Does the PR have limitations?
  6. Does the PR introduce breaking changes?
-->

JIRA: https://hasurahq.atlassian.net/browse/V3ENGINE-148

This is part 1 of supporting field arguments in the engine.
Part 2 is here: https://github.com/hasura/v3-engine/pull/695

It adds the OpenDD types according to the RFC and resolves them.

V3_GIT_ORIGIN_REV_ID: f7736c968489e35c9133f2c6e276d05baf84d4be
2024-06-11 16:31:47 +00:00
Daniel Harvey
e0b8d67309 Break up src/schema/boolean_expressions.rs somewhat (#701)
<!-- Thank you for submitting this PR! :) -->

## Description

The level of nesting in this file makes it hard to follow, this breaks
the deepest nesting into a function. Functional no-op.

V3_GIT_ORIGIN_REV_ID: 03777bdae0c772754f5ca370dcc3d9577abc9c80
2024-06-11 16:09:09 +00:00
Samir Talwar
0c6d6a67d2 Semicolons, everywhere! (#700)
If a function doesn't return a value, terminate with a semicolon.

I also moved `implicit_hasher` and `return_self_not_must_use` to the
"definitely keep disabling this" list, and installed
[Bacon](https://dystroy.org/bacon/) in the Nix shell to make it easier
to run Clippy.

V3_GIT_ORIGIN_REV_ID: ffb17b42d982518aec433a1676dba0a0dd0ad95d
2024-06-11 15:33:32 +00:00
Daniel Harvey
bf069c0e64 Remove erroneous println macro (#698)
<!-- Thank you for submitting this PR! :) -->

## Description

Should have been removed in https://github.com/hasura/v3-engine/pull/680

V3_GIT_ORIGIN_REV_ID: 027d4bb88c32d400cf260677e2fef3802e479af4
2024-06-11 14:25:04 +00:00
Daniel Harvey
d34c419929 Allow nested metadata-resolve tests (#697)
<!-- Thank you for submitting this PR! :) -->

## Description

We have a set of tests in `metadata-resolve` that uses globs to find
files in either `passing` or `failing` folders and check them. This
allows those files to live in nested folders for tidyness. Functional
no-op.

V3_GIT_ORIGIN_REV_ID: 22d42e986676a110f455c59c3df9e6946c5d996c
2024-06-11 14:11:10 +00:00
Samir Talwar
551f43e1bf Auto-generate schema titles that a code generator would like. (#696)
It turns out that code generators based on JSON schemas don't always
play nicely with characters such as `' '` or `'/'`. To work around this,
when we use the schema name as a title, we replace any non-alphanumeric
character or underscore with an underscore (`'_'`).

V3_GIT_ORIGIN_REV_ID: 6af9a92c84c59294ff28bae27d7421627cde6a80
2024-06-11 13:40:45 +00:00
Daniel Harvey
75ced29d11 Resolve nested object boolean expressions (#680)
<!-- Thank you for submitting this PR! :) -->

## Description

This adds the ability to describe nested object boolean expressions,
which become `fieldPath` items in the generated
`ndc_models::ComparisonTarget::Column` items. This allows us to describe
filtering a `User` based on some element in their nested `address` field
(like `postcode`, for example).

Like the other `BooleanExpressionType` work, this remains behind a
feature flag so should make no user-facing changes.

It is also missing a whole heap of metadata resolve checks, going to
follow with these after doing the happy path to unblock other work.

V3_GIT_ORIGIN_REV_ID: c89e2942a651d349fca97706affcf40d91afeefb
2024-06-11 12:57:21 +00:00
Tom Harding
1c6b1dffc8 Remove duplicate JSON Schema entries (#692)
<!-- Thank you for submitting this PR! :) -->

## Description

When we generate a JSON schema via `schemars`, we end up with duplicate
types in the schema, which get names like `ValueExpression2`, `Role2`,
and so on. This isn't ideal, and seems to arise for two reasons:

1. The type is polymorphic, and is monomorphised in two ways, and thus
the types can't be unified.
2. The type is monomorphic, but is used inside and outside of its home
module.

The first problem was fixed previously by splitting polymorphic types,
but the second has proven to be a bit more work. This PR finally solves
the problem by introducing a new library, `jsonschema-tidying`:

* First, we search the definitions within the JSON schema for any whose
names end in a number, such as `ValueExpression2` or `MetadataV2`.
* Then, we look for types whose names match everything up to the final
numeric digits, and discard any types for whom we can't find a match (so
we keep `ValueExpression2` because `ValueExpression` exists, but discard
`MetadataV2` because `MetadataV` does not).
* Next, we remove the duplicate definition from the definitions map,
potentially breaking links in both the schema _and_ the rest of the
definitions map.
* Finally, we traverse the entirety of the tree looking for any
references to the duplicate entry, and replace them with references to
the original entry.

This PR has no direct user-facing change, however it _will_ have an
effect on the docs generation code, which will hopefully result in
tidier documentation.

<!--
  Questions to consider answering:
  1. What user-facing changes are being made?
4. What are issues related to this PR? (Consider adding `(close
#<issue-no>)` to the PR title)
  5. What is the conceptual design behind this PR?
  6. How can this PR be tested/verified?
  7. Does the PR have limitations?
  8. Does the PR introduce breaking changes?
-->

## Changelog

- Add a changelog entry (in the "Changelog entry" section below) if the
changes
  in this PR have any user-facing impact. See
[changelog
guide](https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide).
- If no changelog is required ignore/remove this section and add a
  `no-changelog-required` label to the PR.

### Product

_(Select all products this will be available in)_

- [ ] community-edition
- [ ] cloud
<!-- product : end : DO NOT REMOVE -->

### Type

<!-- See changelog structure:
https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide#structure-of-our-changelog
-->

_(Select only one. In case of multiple, choose the most appropriate)_

- [ ] highlight
- [x] enhancement
- [x] bugfix
- [ ] behaviour-change
- [ ] performance-enhancement
- [ ] security-fix
<!-- type : end : DO NOT REMOVE -->

### Changelog entry

<!--
  - Add a user understandable changelog entry
- Include all details needed to understand the change. Try including
links to docs or issues if relevant
  - For Highlights start with a H4 heading (#### <entry title>)
  - Get the changelog entry reviewed by your team
-->

_Replace with changelog entry_

<!-- changelog-entry : end : DO NOT REMOVE -->

<!-- changelog : end : DO NOT REMOVE -->

V3_GIT_ORIGIN_REV_ID: fe73acf7d9df0b9867852e673e53cb086e3725d3
2024-06-11 08:28:30 +00:00
Philip Lykke Carlsen
c8d89a8ad8 Remove namespace arguments (#691)
<!-- Thank you for submitting this PR! :) -->

## Description

With the introduction of `NamespacedGetter` as the means deciding how to
interpret what it means to extract "namespaced" data from a schema it is
superfluous to thread along the "namespace" that lookups will be based
on.

This PR removes those namespace arguments.

As a nice side effect this removes the cases where we used to have to
supply a dummy role value when generating a role-agnostic schema.

<!--
  Questions to consider answering:
  1. What user-facing changes are being made?
2. What are issues related to this PR? (Consider adding `(close
#<issue-no>)` to the PR title)
  3. What is the conceptual design behind this PR?
  4. How can this PR be tested/verified?
  5. Does the PR have limitations?
  6. Does the PR introduce breaking changes?
-->

## Changelog

- Add a changelog entry (in the "Changelog entry" section below) if the
changes
  in this PR have any user-facing impact. See
[changelog
guide](https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide).
- If no changelog is required ignore/remove this section and add a
  `no-changelog-required` label to the PR.

### Product

_(Select all products this will be available in)_

- [ ] community-edition
- [ ] cloud
<!-- product : end : DO NOT REMOVE -->

### Type

<!-- See changelog structure:
https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide#structure-of-our-changelog
-->

_(Select only one. In case of multiple, choose the most appropriate)_

- [ ] highlight
- [ ] enhancement
- [ ] bugfix
- [ ] behaviour-change
- [ ] performance-enhancement
- [ ] security-fix
<!-- type : end : DO NOT REMOVE -->

### Changelog entry

<!--
  - Add a user understandable changelog entry
- Include all details needed to understand the change. Try including
links to docs or issues if relevant
  - For Highlights start with a H4 heading (#### <entry title>)
  - Get the changelog entry reviewed by your team
-->

_Replace with changelog entry_

<!-- changelog-entry : end : DO NOT REMOVE -->

<!-- changelog : end : DO NOT REMOVE -->

V3_GIT_ORIGIN_REV_ID: 0aca2b3838f1b0d944b3c41ddd54d20dc74503a4
2024-06-10 21:01:34 +00:00
Daniel Harvey
24dc842b43 Add nested select test for Postgres (#693)
<!-- Thank you for submitting this PR! :) -->

## Description

We want to test `where` clauses over nested selects, so first let's get
a working test for selecting everything. Adds new test tables and
updates them in the test metadata etc. Functional no-op.

V3_GIT_ORIGIN_REV_ID: 8ebc6b27379b930eaf2220061c2ec58cd1650167
2024-06-10 15:15:12 +00:00
paritosh-08
133cd6e343 RFC | OpenDD changes for field arguments (#682)
<!-- Thank you for submitting this PR! :) -->

## Description

<!--
  Questions to consider answering:
  1. What user-facing changes are being made?
2. What are issues related to this PR? (Consider adding `(close
#<issue-no>)` to the PR title)
  3. What is the conceptual design behind this PR?
  4. How can this PR be tested/verified?
  5. Does the PR have limitations?
  6. Does the PR introduce breaking changes?
-->

[Rendered
RFC](https://github.com/hasura/v3-engine/blob/paritosh/v3engine-148/open-dd-changes-RFC/rfcs/open-dd-field-argument-types-changes.md)

JIRA: https://hasurahq.atlassian.net/browse/V3ENGINE-148
V3_GIT_ORIGIN_REV_ID: a84c27715a69d20e05bcbf34eae4439669f0fb85
2024-06-10 10:29:26 +00:00
dependabot[bot]
05e13fe566 Bump serde from 1.0.202 to 1.0.203 (#687)
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.202 to 1.0.203.

V3_GIT_ORIGIN_REV_ID: 81b23526c9a289d401260350b8169907eb322bbf
2024-06-10 06:26:06 +00:00
dependabot[bot]
3392ea7d02 Bump build-data from 0.1.5 to 0.2.1 (#688)
Bumps [build-data](https://gitlab.com/leonhard-llc/ops) from 0.1.5 to 0.2.1.

V3_GIT_ORIGIN_REV_ID: 5e2b922820ecb44706f6a628d5dcb60c8ad5df76
2024-06-10 06:01:55 +00:00
dependabot[bot]
ad2005eb26 Bump async-graphql-parser from 7.0.3 to 7.0.6 (#686)
Bumps
[async-graphql-parser](https://github.com/async-graphql/async-graphql) from 7.0.3 to 7.0.6.

V3_GIT_ORIGIN_REV_ID: 9b99211a1da74113c59d5c97d0d86c90924f1084
2024-06-10 05:36:20 +00:00
dependabot[bot]
9b646c7157 Bump bson from 2.10.0 to 2.11.0 (#689)
Bumps [bson](https://github.com/mongodb/bson-rust) from 2.10.0 to 2.11.0.

V3_GIT_ORIGIN_REV_ID: e89e67fbaf4be2c98aabb5b1d504dc4684460763
2024-06-10 05:18:27 +00:00
dependabot[bot]
a707124e65 Bump quote from 1.0.35 to 1.0.36 (#690)
Bumps [quote](https://github.com/dtolnay/quote) from 1.0.35 to 1.0.36.

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
V3_GIT_ORIGIN_REV_ID: 38b333a00206c68aa69bfb4c8b257d2bd1e164f0
2024-06-10 05:00:00 +00:00
Rakesh Emmadi
c1cdc6dc82 add tests for input type infinite recursion bug (#681)
Add a test case for input type infinite recursion bug (https://github.com/hasura/v3-engine/pull/676). I confirmed the
test failure when the fix was removed.

V3_GIT_ORIGIN_REV_ID: b9d0a9b2a65328aa52f5ec057dcba6470c4e3956
2024-06-07 07:00:03 +00:00
Anon Ray
8bc5c01961 Argument presets for DataConnectorLink Pt. 2 (#675)
## Description

This PR implements argument presets for `DataConnectorLink`, which can
be used to forward request headers as function/procedure arguments to
NDC. This PR implements the execution part.

**Note**: response header forwarding is not implemented yet.

V3_GIT_ORIGIN_REV_ID: ff69129aee3e3052367ca42acdec3922cbc2cb0c
2024-06-06 16:04:28 +00:00
Daniel Harvey
d090331be2 Factor source_data_connector out of relationship (#679)
<!-- Thank you for submitting this PR! :) -->

## Description

We'd like not to tie our boolean expressions to one particular data
connector, we were doing this in relationships and had no need to.
Functional no-op.

V3_GIT_ORIGIN_REV_ID: 0af16ad92117a45ac1f424b49d9f13184787f63f
2024-06-06 15:14:02 +00:00
Anon Ray
90444710cb Argument presets for DataConnectorLink Pt. 1 (#667)
## Description

This PR implements argument presets and response headers for
`DataConnectorLink`, which can be used to forward request headers as
function/procedure arguments to NDC, and also forward response headers
from NDC back to the client. This PR implements only the OpenDD changes
and metadata resolving part.

V3_GIT_ORIGIN_REV_ID: 2b7f20af7c2f192c0103553bccb000114dcba916
2024-06-06 14:55:09 +00:00
Philip Lykke Carlsen
1960918d0c Expose separate function to introspect for a single role (#677)
<!-- Thank you for submitting this PR! :) -->

## Description

This PR is a refactoring which is a functional no-op.

<!--
  Questions to consider answering:
  1. What user-facing changes are being made?
2. What are issues related to this PR? (Consider adding `(close
#<issue-no>)` to the PR title)
  3. What is the conceptual design behind this PR?
  4. How can this PR be tested/verified?
  5. Does the PR have limitations?
  6. Does the PR introduce breaking changes?
-->

## Changelog

- Add a changelog entry (in the "Changelog entry" section below) if the
changes
  in this PR have any user-facing impact. See
[changelog
guide](https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide).
- If no changelog is required ignore/remove this section and add a
  `no-changelog-required` label to the PR.

### Product

_(Select all products this will be available in)_

- [ ] community-edition
- [ ] cloud
<!-- product : end : DO NOT REMOVE -->

### Type

<!-- See changelog structure:
https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide#structure-of-our-changelog
-->

_(Select only one. In case of multiple, choose the most appropriate)_

- [ ] highlight
- [ ] enhancement
- [ ] bugfix
- [ ] behaviour-change
- [ ] performance-enhancement
- [ ] security-fix
<!-- type : end : DO NOT REMOVE -->

### Changelog entry

<!--
  - Add a user understandable changelog entry
- Include all details needed to understand the change. Try including
links to docs or issues if relevant
  - For Highlights start with a H4 heading (#### <entry title>)
  - Get the changelog entry reviewed by your team
-->

_Replace with changelog entry_

<!-- changelog-entry : end : DO NOT REMOVE -->

<!-- changelog : end : DO NOT REMOVE -->

V3_GIT_ORIGIN_REV_ID: 625475ef23ef7fd2f72921e951fa1a957807516a
2024-06-06 12:11:37 +00:00
Daniel Harvey
58f939e605 Use OperatorMappings in boolean expressions (#674)
Previously we required an operator called `_eq` to be called `_eq` in
all data connectors that used it.

Now we can give them nice names, and map each one to a different
operator name per data connector.

V3_GIT_ORIGIN_REV_ID: 1d2f678e25d932e5ea45d34999cf5709ef0038b4
2024-06-06 11:31:36 +00:00
Daniel Harvey
560cc5755c Make only one failing instance in each test (#678)
<!-- Thank you for submitting this PR! :) -->

## Description

Very occasionally these tests fail with the wrong duplicated graphql
name. Not sure why, I assume some unpredictable HashMap ordering
somewhere. In lieu of changing all HashMaps to BTreeMaps in engine
(which isn't immediately possible because of missing `Ord` instances for
`serde_json::Value`), let's make only one set of failing items in these
tests so the same one goes wrong each time.

Functional no-op.

V3_GIT_ORIGIN_REV_ID: 6dff998ae66aedbcca05dd05dc6fcb12e6d704c3
2024-06-06 11:04:14 +00:00
Rakesh Emmadi
49e0c79d9e avoid infinite recursion in building annotations from input types (#676)
## Description
JIRA: https://hasurahq.atlassian.net/browse/V3ENGINE-180

Fix an edge case where the function
`build_annotations_from_input_object_type_permissions` produce infinite
recursions
when an input object type contains fields with self-referential types.

Note: This PR doesn't contain any tests. They'll be added in a separate
PR ([JIRA](https://hasurahq.atlassian.net/browse/V3ENGINE-188)). This
fix needs to be done quickly and merged as other teams (graphql
connector) are blocked by this.
V3_GIT_ORIGIN_REV_ID: 4cc09cb96871804d4daf83d7e49a6f4529c1943d
2024-06-06 08:16:33 +00:00
Daniel Chambers
e147721983 Revise the Aggregates RFC to add missing descriptions (#666)
The original Aggregates RFC is missing some descriptions fields in its
specification of the Open DD metadata, which means that those particular
items currently don't get a description in GraphQL.

This PR adds the missing descriptions to the RFC document.

V3_GIT_ORIGIN_REV_ID: a93d5d92c427fe95f85ed3889660d2c22bc08f5a
2024-06-06 03:42:02 +00:00
Daniel Harvey
2cd613077a Make very happy path BooleanExpressionType work (#673)
<!-- Thank you for submitting this PR! :) -->

## Description

This makes the absolute happiest path `BooleanExpressionType` work.

Caveats:

- We ignore operator mappings, so we assume that the OpenDD operator
name (ie, `_eq`) is the same as the data connector's name for it.

- We have not tried to implement `comparisonRelationships` in any way
yet.

- Have not tried nested objects yet.

All functionality here is behind a feature flag so has no user-facing
impact.

V3_GIT_ORIGIN_REV_ID: 5edb706c6d8b03b9fa59433ce24f05f37a69729a
2024-06-05 16:18:28 +00:00
Anon Ray
52cfca7f91 fix: ndc validation of command (#669)
## Description

There is a bug in NDC validation of command where it returns early
without validating. This is because we perform the NDC validation right
after resolving the command source, but haven't attached the "resolved
command source" to the command yet. As a result the command's source is
`None`, and the validation does an early return.

This PR fixes it by taking the command source directly. If there is no
source to resolve, we don't have to perform any NDC validation of the
command.

Note: this is not the case with models. Model's source resolving
attaches the "resolved source", then performs the validation.

## Changelog

- Add a changelog entry (in the "Changelog entry" section below) if the
changes
  in this PR have any user-facing impact. See
[changelog
guide](https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide).
- If no changelog is required ignore/remove this section and add a
  `no-changelog-required` label to the PR.

### Product

_(Select all products this will be available in)_

- [x] community-edition
- [x] cloud
<!-- product : end : DO NOT REMOVE -->

### Type

<!-- See changelog structure:
https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide#structure-of-our-changelog
-->

_(Select only one. In case of multiple, choose the most appropriate)_

- [ ] highlight
- [ ] enhancement
- [x] bugfix
- [ ] behaviour-change
- [ ] performance-enhancement
- [ ] security-fix
<!-- type : end : DO NOT REMOVE -->

### Changelog entry

<!--
  - Add a user understandable changelog entry
- Include all details needed to understand the change. Try including
links to docs or issues if relevant
  - For Highlights start with a H4 heading (#### <entry title>)
  - Get the changelog entry reviewed by your team
-->

Fix skipping of NDC validation of commands due to wrong assumption.

<!-- changelog-entry : end : DO NOT REMOVE -->

<!-- changelog : end : DO NOT REMOVE -->

V3_GIT_ORIGIN_REV_ID: 5b9f4c922ee83394f1b6fe840cd934b6e138e2e9
2024-06-05 15:40:31 +00:00
Daniel Harvey
b314d89ff0 Use newtypes for operator names (#672)
<!-- Thank you for submitting this PR! :) -->

## Description

We were using `String` for these, and making some assumptions about NDCs
and OpenDD operator names being the same. This uses newtypes and
documents where these assumptions are being made. Functional no-op.

V3_GIT_ORIGIN_REV_ID: 195e55db6fadf48c956684130e23f647eaa17fb1
2024-06-05 14:46:05 +00:00
Samir Talwar
ca830c05fb Be more explicit about clones, and remove a few. (#671)
Calling `.to_owned()` on a reference, `.to_vec()` on a vector reference,
etc. are just synonyms for `.clone()` which are less explicit about
cloning. Let's be explicit.

This also removes some unnecessary clones.

V3_GIT_ORIGIN_REV_ID: 1bc00c4106f0346303d73e4268c89030c0ce93fc
2024-06-05 13:26:33 +00:00
Anon Ray
f62f95f30c gardening: tidy up data connector resolve types (#668)
## Description

Tiny PR to add some comments and clarifications to the data connector
resolve types.

Also, rearranges the types and functions to make the flow clearer.

V3_GIT_ORIGIN_REV_ID: db5b18cbd7c79670c9dfc68c80950ccf5105f9ce
2024-06-05 10:34:57 +00:00
Anon Ray
8064c292b5 upgrade to ndc v0.1.3 (#629)
Upgrade engine to ndc v0.1.3.

Also updates custom connector.

---------

Co-authored-by: Samir Talwar <samir.talwar@hasura.io>
Co-authored-by: Gil Mizrahi <gil@hasura.io>
V3_GIT_ORIGIN_REV_ID: 80959d4702ef785b7809d6432e092b6477ef88c1
2024-06-05 10:16:11 +00:00
Samir Talwar
7281322f51 Enable a few lint warnings around conditions, and fix the highlighted areas. (#662)
1. Use `map_or(…, …)` instead of `.map(…).unwrap_or(…)`.
2. Use `.is_some_and(…)` instead of `.map(…).unwrap_or_default(…)`.
3. Nest `|` patterns where possible.
4. Be more specific about match patterns.

I found I could also simplify `typecheck_qualified_type_reference`
considerably.

V3_GIT_ORIGIN_REV_ID: 6a3b1a4c525c0187c2fdb6df0c979ca0b7b3016c
2024-06-05 08:42:03 +00:00
Samir Talwar
52f82d52c1 Use "dev" as the version in development for Nix builds. (#665)
This means we can use the cache far more often.

Pull requests will also use "dev" so as to avoid rebuilding
unnecessarily. Only builds on the `main` branch and tags will set a
version (using the short Git commit hash).

V3_GIT_ORIGIN_REV_ID: 37acaec3d369eef6df6487f9612f6d2da3e3ba5a
2024-06-05 08:20:49 +00:00
Daniel Harvey
d8b1fbcce7 Remove scalar_type_name where not needed (#663)
<!-- Thank you for submitting this PR! :) -->

## Description

We pass around `scalar_type_name` but never need it, removing it makes
boolean expressions easier to implement, so split into a fresh PR.
Functional no-op.

V3_GIT_ORIGIN_REV_ID: 0e4df8da4cb15d90a7f7be068b40c47936b70734
2024-06-04 15:40:50 +00:00
Samir Talwar
a793fd479d Use Nix to build and publish Docker images. (#664)
## Description

We can use Nix to build Docker images, which gives us a few advantages:

1. the images will be cached a little better
2. aarch64 builds become easy
3. Samir is happy because the Nixification continues

## Changelog

- Add a changelog entry (in the "Changelog entry" section below) if the
changes
  in this PR have any user-facing impact. See
[changelog
guide](https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide).
- If no changelog is required ignore/remove this section and add a
  `no-changelog-required` label to the PR.

### Product

_(Select all products this will be available in)_

- [x] community-edition
- [ ] cloud
<!-- product : end : DO NOT REMOVE -->

### Type

<!-- See changelog structure:
https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide#structure-of-our-changelog
-->

_(Select only one. In case of multiple, choose the most appropriate)_

- [ ] highlight
- [x] enhancement
- [ ] bugfix
- [ ] behaviour-change
- [ ] performance-enhancement
- [ ] security-fix
<!-- type : end : DO NOT REMOVE -->

### Changelog entry

<!--
  - Add a user understandable changelog entry
- Include all details needed to understand the change. Try including
links to docs or issues if relevant
  - For Highlights start with a H4 heading (#### <entry title>)
  - Get the changelog entry reviewed by your team
-->

The v3 engine and dev-auth-webhook Docker images are now published for
both x86_64 (`amd64`) and aarch64 (`arm64`) architectures.

<!-- changelog-entry : end : DO NOT REMOVE -->

<!-- changelog : end : DO NOT REMOVE -->

Co-Authored-By: Philip Carlsen <philip@hasura.io>
Co-Authored-By: Gil Mizrahi <gil@hasura.io>
V3_GIT_ORIGIN_REV_ID: ae6fec45dee62a21f03b5258b57d841a16542c72
2024-06-04 14:15:41 +00:00
Philip Lykke Carlsen
18efbe9380 Add ability to override interpretations of roles (#660)
This PR refactors the schema crate to enable overriding the
interpretation of roles at runtime.

By providing a `NamespacedGetter` that ignores roles entirely (i.e.
`GDSNamespacedGetterAgnostic`) to schema generation functions it is
possible to derive a GraphQL schema that ignores permissions and
presets.

This PR leaves back a few opportunities to improve code clarity, which I
hope to address in follow-up PRs.
For instance, it seems superfluous to make sense for generic code
parametrised `<S: SchemaContext>` to carry around both a `S::Namespace`
and a `S::NamespaceGetter`, when all that code could ever do with that
`S::Namespace` value anyway is apply it to the `S::NamespaceGetter`.
Taking this line of reasoning to its conclusion suggests that we can
reduce the complexity of `trait SchemaContext` and its associated types
and kit.

---------

Co-authored-by: Samir Talwar <samir.talwar@hasura.io>
V3_GIT_ORIGIN_REV_ID: c84555fd88279582670919faa5a62bbd00b714bd
2024-06-04 13:04:36 +00:00
Samir Talwar
40e23db51e Apply a few lints to make it struct construction clearer. (#661)
1. Always name the struct when calling `default()`.
2. Sort construction according to the definitions.
3. Approve allowing `struct_field_names` because it doesn't seem to be
helpful.
4. Enable `manual_string_new`; nothing seems to be triggering it now.

V3_GIT_ORIGIN_REV_ID: 868742114b0bf27bc3ea03cdf1e63a0f710ebe33
2024-06-04 08:42:48 +00:00
Daniel Harvey
e36794da51 Break up schema/boolean-expressions ready for new bool exps (#659)
<!-- Thank you for submitting this PR! :) -->

## Description

Broke this out of new bool exps work, breaks this big function into
smaller functions with clearer dependencies. Functional no-op.

V3_GIT_ORIGIN_REV_ID: 4f85132f9c381977b1cd406bb71e278c45866691
2024-06-03 19:45:28 +00:00
Daniel Harvey
5fd6b6c03a Resolve boolean_expression_type metadata (#630)
<!-- Thank you for submitting this PR! :) -->

## Description

This somewhat resolves the `BooleanExpressionType` metadata type.

There is a lot that is missing, but everything is behind a feature so I
want to merge what is here before moving onto getting it working with
the later parts of the pipeline. We'll start with a lot of duplication
and then work to remove as much as we can.

Functional no-op for users, the feature flag is not exposed to the
actual binary.

How to review this PR:

- Check that any changes to existing code are cosmetic and naming-only
to ensure this is a no-op
- Look through the new resolve step and compare it to the
[RFC](https://github.com/hasura/v3-engine/blob/main/rfcs/open-dd-expression-type-changes.md)
and see if it is doing roughly what you might expect.
- Don't get too bogged down in missing things / style stuff, there are
definitely missing things and bad style.

V3_GIT_ORIGIN_REV_ID: 24e3b3e72e62d0094db3b461cb8c6d359982755d
2024-06-03 13:35:49 +00:00
Samir Talwar
d8277974a8 Move a couple of lint suppressions closer to the code. (#658)
Rather than allowing the `cast_precision_loss` and `inline_always`
warnings everywhere, we just suppress them in the few places they're
already used.

V3_GIT_ORIGIN_REV_ID: c28350a21efa029c8c6aae2a602eec2d75f42216
2024-06-03 12:16:14 +00:00
Daniel Harvey
bf9af51c2a Defer resolving field mappings (#651)
<!-- Thank you for submitting this PR! :) -->

## Description

The field mappings for an object type are the mappings between the
OpenDD field name (`FieldName`) and whatever the NDC column name
(`DataConnectorColumnName`) are.

Type mappings is a map from OpenDD type names
(`Qualified<CustomTypeName>`) to the field mappings for that type.

Previously, Boolean Expressions were attached to a single data connector
and object type. Now we are generalising them so that they can be used
across any of the multiple data connectors that their attached
ObjectType might have type mappings for.

To do this, we stop including them in the resolved
`ObjectBooleanExpressionType`, and instead fetch the relevant type
mappings from whichever thing is using the boolean expression type,
usually the `ModelSource` for a `Model`.

Functional no-op.

V3_GIT_ORIGIN_REV_ID: 4a251473b4aecedf4ede0e79aa7b577e25207cb8
2024-06-03 10:56:34 +00:00
Daniel Harvey
39c45de522 Add UNSTABLE_FEATURES env var (#652)
<!-- Thank you for submitting this PR! :) -->

## Description

We'd like to be able to test new WIP experimental features. This adds a
`UNSTABLE_FEATURES` env var / command line arg that can be passed a
comma separated list of names.

Currently we accept `UNSTABLE_FEATURES=enable-boolean-expression-types`
but in future users could pass
`UNSTABLE_FEATURES=some-fancy-feature,other-feature,great`.

<!--
  Questions to consider answering:
  1. What user-facing changes are being made?
2. What are issues related to this PR? (Consider adding `(close
#<issue-no>)` to the PR title)
  3. What is the conceptual design behind this PR?
  4. How can this PR be tested/verified?
  5. Does the PR have limitations?
  6. Does the PR introduce breaking changes?
-->

## Changelog

- Add a changelog entry (in the "Changelog entry" section below) if the
changes
  in this PR have any user-facing impact. See
[changelog
guide](https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide).
- If no changelog is required ignore/remove this section and add a
  `no-changelog-required` label to the PR.

### Product

_(Select all products this will be available in)_

- [x] community-edition
- [x] cloud
<!-- product : end : DO NOT REMOVE -->

### Type

<!-- See changelog structure:
https://github.com/hasura/graphql-engine-mono/wiki/Changelog-Guide#structure-of-our-changelog
-->

_(Select only one. In case of multiple, choose the most appropriate)_

- [ ] highlight
- [x] enhancement
- [ ] bugfix
- [ ] behaviour-change
- [ ] performance-enhancement
- [ ] security-fix
<!-- type : end : DO NOT REMOVE -->

### Changelog entry

<!--
  - Add a user understandable changelog entry
- Include all details needed to understand the change. Try including
links to docs or issues if relevant
  - For Highlights start with a H4 heading (#### <entry title>)
  - Get the changelog entry reviewed by your team
-->

Add `UNSTABLE_FEATURES` environment variable

<!-- changelog-entry : end : DO NOT REMOVE -->

<!-- changelog : end : DO NOT REMOVE -->

V3_GIT_ORIGIN_REV_ID: 3562c1341d4ea3a512626110dbd2b055425c1d60
2024-06-03 08:50:43 +00:00
dependabot[bot]
8248958b81 Bump strum_macros from 0.26.2 to 0.26.3 (#653)
V3_GIT_ORIGIN_REV_ID: f226b53a3a61ea3d71bde72eb024373a27f0abc5
2024-06-03 07:48:13 +00:00