Commit Graph

8522 Commits

Author SHA1 Message Date
Daniel Harvey
aec5a6d0cb Split boolean expression errors (#829)
### What
Part of ongoing tidy up of errors, this splits out errors types for the
boolean expression stages.

### How
Remove things from `Error`, move files around. Functional no-op.

V3_GIT_ORIGIN_REV_ID: ccf1f29600a169a3787d744c7f60e79220aef8d2
2024-07-15 05:31:57 +00:00
Daniel Harvey
db96e42358 Explicitly import thiserror::Error in place (#827)
<!-- The PR description should answer 2 (maybe 3) important questions:
-->

### What

To stop us being confused between `Error` type and `Error` trait.

<!-- What is this PR trying to accomplish (and why, if it's not
obvious)? -->

<!-- Consider: do we need to add a changelog entry? -->

### How

Import `thiserror::Error` explicitly in place.

<!-- How is it trying to accomplish it (what are the implementation
steps)? -->

V3_GIT_ORIGIN_REV_ID: b930480927b2c64537960cfb69f2b2b30921f4fd
2024-07-11 15:18:27 +00:00
Daniel Chambers
7efcb2e4f6 Fix custom connector schema and update all tests to use up-to-date schema (#826)
This PR fixes the custom connector whose schema endpoint doesn't
actually return correct output (it was missing some
functions/procedures, etc). Then it updates all tests that actually talk
to the custom connector with the latest version of its
schema/capabilities in their DataConnectorLink.

This test update is done by a new script added to the justfile that
finds and patches all metadata json files and inserts the new schema and
capabilities after reading them from the custom connector running in
docker.

V3_GIT_ORIGIN_REV_ID: f1825a6f74ddcb6c01198fe4a41de6b4fc0bf533
2024-07-11 14:15:58 +00:00
Daniel Harvey
63279ccb38 Combine all Apollo errors (#824)
<!-- The PR description should answer 2 (maybe 3) important questions:
-->

### What

As a treat, combine all Apollo errors into one enum.

<!-- What is this PR trying to accomplish (and why, if it's not
obvious)? -->

<!-- Consider: do we need to add a changelog entry? -->

### How

Remove items from `ObjectTypesError` and `Error`.

<!-- How is it trying to accomplish it (what are the implementation
steps)? -->

V3_GIT_ORIGIN_REV_ID: 5a16a030b35372283490f3de7343fcfca2fadea5
2024-07-11 10:16:24 +00:00
Samir Talwar
62fa071663 Use the release version as the relevant tracing attribute. (#823)
### What

And don't set it except for the main application; tests and test
infrastructure does not care.

### How

We use the `VERSION` constant, populated from the `RELEASE_VERSION`
environment variable at build time.

It's now also optional so tests don't have to specify it.

V3_GIT_ORIGIN_REV_ID: 1bfc2efb060307cc9446bf07e944e107f0607ae0
2024-07-11 07:32:30 +00:00
ashwiniag
43028b6c66 ci: catalog update v2.41.0
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10930
GitOrigin-RevId: 3570f0999d0bafa9b22f89baf38f7494e7bd8de4
2024-07-10 10:48:55 +00:00
Daniel Harvey
44b07f8055 release v2024.07.10 (#818)
<!-- The PR description should answer 2 (maybe 3) important questions:
-->

### What

Update changelogs for new release.

<!-- What is this PR trying to accomplish (and why, if it's not
obvious)? -->

<!-- Consider: do we need to add a changelog entry? -->

### How

<!-- How is it trying to accomplish it (what are the implementation
steps)? -->

V3_GIT_ORIGIN_REV_ID: 7adfd3c2c53b912bb7c4604ebed93601a201c15e
2024-07-10 10:00:03 +00:00
Daniel Chambers
cf44277811 Removed ndc_models usage from field arguments IR (#816)
This PR removes the usage of ndc_models in the field arguments IR and
uses the actual arguments IR instead. This change was missed in #810.

V3_GIT_ORIGIN_REV_ID: 414b4eda9724e7702b5a09ea2855b457d7ce88d6
2024-07-10 07:44:35 +00:00
Daniel Harvey
ab1d963de0 Split ValueExpression (#812)
### What
`ValueExpression` contained boolean expressions, and was used in places
where boolean expressions were not allowed.

### How
This creates a new type `ValueExpressionOrPredicate`, and uses it in the
places where boolean expressions are allowed.

---------

Co-authored-by: Daniel Chambers <daniel@hasura.io>
V3_GIT_ORIGIN_REV_ID: c0a07c5e0096aeb4369ca7d6b5147451d1ccd14d
2024-07-10 02:30:09 +00:00
Brandon Martin
b2e0843045 Add python script to get cabal package licenses
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10928
GitOrigin-RevId: d26495c8c9975b9e4f98e322b6d5b2977e66c247
2024-07-09 21:39:07 +00:00
Shahidh K Muhammed
a94bace075 docs: update the dependencies to include console as well
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10927
GitOrigin-RevId: b85d3bf57d78996451ef548708186348ad09f823
2024-07-09 21:09:13 +00:00
Daniel Harvey
f6f4785e7c Error type for object_types stage (#814)
<!-- The PR description should answer 2 (maybe 3) important questions:
-->

### What

Break down the big `Error` enum some more. This time, add all errors
from the `object_types` stage into the `ObjectTypesError` enum.

<!-- What is this PR trying to accomplish (and why, if it's not
obvious)? -->

<!-- Consider: do we need to add a changelog entry? -->

### How

Moving code around. Functional no-op.

<!-- How is it trying to accomplish it (what are the implementation
steps)? -->

V3_GIT_ORIGIN_REV_ID: 154d4b40b21365c783d545a23cf18be623f2a3de
2024-07-09 20:21:46 +00:00
Shahidh K Muhammed
1e8096b1a3 docs: update ee 3rd party dependency list
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10924
GitOrigin-RevId: 33884b2efd254db70a100f398546cb8b2468a759
2024-07-09 19:35:34 +00:00
Daniel Harvey
55dcab09b1 Split up apollo and relay stages (#815)
<!-- The PR description should answer 2 (maybe 3) important questions:
-->

### What

In the haste of breaking things up, realised we put the `relay` checks
in with the `apollo` ones where they are two separate things.

<!-- What is this PR trying to accomplish (and why, if it's not
obvious)? -->

<!-- Consider: do we need to add a changelog entry? -->

### How

Split up `apollo` step into `relay` and `apollo` steps. Functional
no-op.

<!-- How is it trying to accomplish it (what are the implementation
steps)? -->

V3_GIT_ORIGIN_REV_ID: 8d02d3cb77b1248239be37ed61d0b87b9b734fdf
2024-07-09 17:19:37 +00:00
Daniel Harvey
788fd9e197 Newtypes around object collections (#807)
<!-- The PR description should answer 2 (maybe 3) important questions:
-->

### What

We pass around a lot of `BTreeMap` and `IndexMap` types. This has two
problems:

a) everytime we change the items inside, we have to manually update lots
of call sites
b) we can't attach useful behaviour to it

<!-- What is this PR trying to accomplish (and why, if it's not
obvious)? -->

<!-- Consider: do we need to add a changelog entry? -->

### How

This adds some wrappers around `object_types`, and adds a `.get()`
function with a useful default error. This error only contains the
missing `type_name`, so the idea is that it would be wrapped in another
error that would provide more context. The hope is that we can get away
from one giant error enum, and instead have a set of smaller error types
that live along each resolving stage.

In isolation this PR isn't very interesting, as it's a tiny drop in the
ocean, so really it's here to say, "is this a thing we vaguely like?"

<!-- How is it trying to accomplish it (what are the implementation
steps)? -->

V3_GIT_ORIGIN_REV_ID: 804a703d7155ce5b929937689d5649c6571357b0
2024-07-09 16:26:58 +00:00
Daniel Harvey
adc1ad5bf9 Break out DataConnectorError (#813)
<!-- The PR description should answer 2 (maybe 3) important questions:
-->

### What

Put all the errors that happen in the `data_connectors` stage into a new
type `DataConnectorError`.

<!-- What is this PR trying to accomplish (and why, if it's not
obvious)? -->

<!-- Consider: do we need to add a changelog entry? -->

### How

Moving enum members to the new type. Functional no-op.

<!-- How is it trying to accomplish it (what are the implementation
steps)? -->

V3_GIT_ORIGIN_REV_ID: 2e50eb561ce6b7c7fac4de4b31c9957f7ee4696c
2024-07-09 15:55:22 +00:00
Varun Choudhary
eca38b949d console: fix import api kriti template issue
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10923
GitOrigin-RevId: c83c53fabfd8fe6d1e4f8319770ce915d604ea6f
2024-07-09 15:40:19 +00:00
Rob Dominguez
989a595f20 Docs: Add support ticket information
[DOCS-2156]: https://hasurahq.atlassian.net/browse/DOCS-2156?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10913
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
GitOrigin-RevId: 50d74ee9a460a8942f97b8c5a013d82ffb60b967
2024-07-09 15:00:52 +00:00
Daniel Harvey
054600d4d3 Move errors to type_permissions stage (#809)
<!-- The PR description should answer 2 (maybe 3) important questions:
-->

### What

Much like https://github.com/hasura/v3-engine/pull/808, move an error to
the place it is thrown.

<!-- What is this PR trying to accomplish (and why, if it's not
obvious)? -->

<!-- Consider: do we need to add a changelog entry? -->

### How

Move files around. Functional no-op.

<!-- How is it trying to accomplish it (what are the implementation
steps)? -->

V3_GIT_ORIGIN_REV_ID: a61527b57662efada2c7d2049e12f103deec1e4e
2024-07-09 11:58:57 +00:00
Daniel Harvey
83df9e81bb Move GraphqlConfigError to graphql_config stage (#808)
<!-- The PR description should answer 2 (maybe 3) important questions:
-->

### What

We have a giant error file in `metadata-resolve`, and it's really
unclear what can go wrong where. Let's improve it in some small way.

<!-- What is this PR trying to accomplish (and why, if it's not
obvious)? -->

<!-- Consider: do we need to add a changelog entry? -->

### How

Move `GraphqlConfigError` to the `graphql_config` stage, and make that
stage only return that kind of error.

Functional no-op.

<!-- How is it trying to accomplish it (what are the implementation
steps)? -->

---------

Co-authored-by: Samir Talwar <samir.talwar@hasura.io>
V3_GIT_ORIGIN_REV_ID: 9aa58875a24d66e6945c9ead6434fedb124f1dd8
2024-07-09 10:02:40 +00:00
Daniel Chambers
1564fcce17 Remove usage of ndc_models Expression types from the IR (#810)
This PR removes the usage of `ndc_models` `Expression` types from the
IR. It then adds logic to map from the new IR `FilterExpression` types
to `ndc_models` types in the plan part of the code where IR ->
ndc_models mapping is performed. The new IR types and the change to the
IR creation logic is mostly in `crates/execute/src/ir/filter.rs`.

The new IR types have some optimisations applied to them. In particular,
some basic boolean expression simplification logic is applied when
`FilterExpression::mk_and` `mk_or` and `mk_not` are used. This strips
out redundant and/ors/nots resulting in simpler boolexps for connectors
to process. (This logic is similar to what GDC did in Hasura v2).

Unfortunately it turned out that arguments had JSON-serialized
`ndc_models` types embedded in them, in particular, where argument
presets had been used to set a BooleanExpression as an argument value.
The old code was simply creating an ndc_models::Expression and
serializing it directly to JSON. This has now been refactored to retain
the new IR `FilterExpression` until `plan` time, at which point it will
be mapped into the ndc type and serialized to JSON and embedded in the
argument value. The types change for this can be seen in
`crates/execute/src/ir/arguments.rs`, but the real logic is actually in
`crates/execute/src/ir/permissions.rs`, with the
`make_value_from_value_expression` and
`make_argument_from_value_expression` functions.

The mapping of expression and argument IR into `ndc_models` can be found
in `crates/execute/src/plan/common.rs`.

In `metadata_resolve`, some ndc_models types were removed and
non-ndc_model types were used instead. In particular
`ndc_models::ComparisonOperatorName` (swapped with
`DataConnectorOperatorName`) and `ndc_models::UnaryComparisonOperator`
(swapped with a new `UnaryComparisonOperator` enum type).

This PR is a functional no-op, other than the boolean expression
simplification.

V3_GIT_ORIGIN_REV_ID: 13805430fb2e2ca5653406a094d719138f0d5b51
2024-07-09 08:23:24 +00:00
dependabot[bot]
f8a2abc0df Bump serde from 1.0.203 to 1.0.204 (#801)
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.203 to 1.0.204.

V3_GIT_ORIGIN_REV_ID: cbe13bf30a6aa7cc5480d174d7d435f18a5cc7f2
2024-07-09 06:54:43 +00:00
Daniel Harvey
8579570459 Add deprecation notice to old boolean expression types (#806)
<!-- The PR description should answer 2 (maybe 3) important questions:
-->

### What

Since these code comments end up in the docs, let's make sure we point
out these old types are no longer in favour.

<!-- What is this PR trying to accomplish (and why, if it's not
obvious)? -->

<!-- Consider: do we need to add a changelog entry? -->

### How

Updating doc comments.

<!-- How is it trying to accomplish it (what are the implementation
steps)? -->

V3_GIT_ORIGIN_REV_ID: a21190fbf2327e1ae265c76d1f467af063f1dd64
2024-07-08 14:19:28 +00:00
Daniel Harvey
29ccf96784 Skip capability check for local relationships (#805)
<!-- The PR description should answer 2 (maybe 3) important questions:
-->

### What

If the target data connector for a relationship does not have the
`foreach` capability, we threw an error, however we should allow this.

<!-- What is this PR trying to accomplish (and why, if it's not
obvious)? -->

<!-- Consider: do we need to add a changelog entry? -->

### How

<!-- How is it trying to accomplish it (what are the implementation
steps)? -->

Check data connector names for relationship target before throwing
capability error.

V3_GIT_ORIGIN_REV_ID: 157908f0077b7c3af67a77600e5f8c9fc65df7f2
2024-07-08 13:03:13 +00:00
Anon Ray
aa77448b2f docs: document known issue of invalid JWT padding by AWS Cognito + ELB
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10919
GitOrigin-RevId: 682d3918a3f018fd6c7d1d6a2b9ecdb6fca66df1
2024-07-08 12:18:03 +00:00
dependabot[bot]
7a0eb6847a Bump async-trait from 0.1.80 to 0.1.81 (#804)
Bumps [async-trait](https://github.com/dtolnay/async-trait) from 0.1.80 to 0.1.81.

V3_GIT_ORIGIN_REV_ID: 1e9a6a6a40b6b0f732774df1e7a52b8a182f70c1
2024-07-08 08:32:04 +00:00
dependabot[bot]
0d9bb020f1 Bump serde_json from 1.0.119 to 1.0.120 (#803)
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.119 to 1.0.120.

V3_GIT_ORIGIN_REV_ID: 0c432282a8ae7daaca22a608881ed0f69da8dd4a
2024-07-08 08:02:06 +00:00
dependabot[bot]
5feabdfd08 Bump syn from 2.0.68 to 2.0.69 (#802)
Bumps [syn](https://github.com/dtolnay/syn) from 2.0.68 to 2.0.69.

V3_GIT_ORIGIN_REV_ID: 6e8a895e4b928418e87c820effcdfbbecdfbfba7
2024-07-08 07:32:24 +00:00
dependabot[bot]
0be3e9f6c0 Bump serde_with from 3.8.2 to 3.8.3 (#800)
Bumps [serde_with](https://github.com/jonasbb/serde_with) from 3.8.2 to 3.8.3

V3_GIT_ORIGIN_REV_ID: d2b0fbecea1997959f644b90c2a57075635a0293
2024-07-08 07:03:01 +00:00
Sean Park-Ross
122abb5f46 Docs: sanitize bot user input
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10920
GitOrigin-RevId: c02782fb63ff2f2f46c1bba532b0539d2d217b8c
2024-07-05 12:49:45 +00:00
Philip Lykke Carlsen
69219958d6 Postgres: Quote custom scalar types in SQL
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10914
GitOrigin-RevId: 1ea4690b801913b4fc3fa8631090e3caa76b1cdc
2024-07-05 12:22:49 +00:00
Daniel Chambers
90dbbccce5 Remove ndc_models types from arguments and order by IR (#798)
Note: This PR is stacked on #797 and should be merged after it.

This PR removes the use of ndc_models types from the arguments and order
by IR. It then shifts the logic that maps the IR to the ndc_models into
the plan part of the code where IR -> ndc_model mapping is performed.

This will help isolate the IR from ndc_models and move us towards being
able to have multiple IR -> ndc_models mapping codes, one per supported
ndc version.

This is a functional no-op PR.

V3_GIT_ORIGIN_REV_ID: 66be868ff4c8185c6190537d570d88813cb7f410
2024-07-05 10:44:41 +00:00
Daniel Chambers
e44589931c Reimplement most OpenDD newtypes using SmolStr and a macro (#797)
This PR replaces most of the string newtypes in the open-dds crate with
new implementations based on `SmolStr`, using a macro adapted from the
macro used in ndc-models. `SmolStr` usage should result in less heap
allocations and the macro ensures all the newtypes get all the same
trait implementations (such as various `From` and `Borrow` instances)
and helper impl functions (such as `as_str`).

The new macro, `str_newtype`, creates a newtype wrapper around `SmolStr`
or another type (typically `Identifier`), and writes out all the various
trait implementations. It also takes a documentation string which
ensures that every newtype has a description in JSON Schema.

The changes in the downstream crates are just adjusting to use the new
newtypes.

Also:
* `QueryGraphqlConfig` used a lot of String typed-properties; these have
been changed for the appropriate `GraphQlTypeName` and
`GraphQlFieldName` types.
* metadata-resolve had a duplicate newtype called
`ConnectorArgumentName`, which duplicated open-dds's
`DataConnectorArgumentName`. This has been removed and replaced.
* A new newtype called `CollectionName` has been added in open-dds to
represent the name of the ndc collection that a model points to. This
was previously just a string.
V3_GIT_ORIGIN_REV_ID: d5a33756ef0e110b2255478358a38e42e6ff89a2
2024-07-05 10:16:33 +00:00
Philip Lykke Carlsen
9910df8154 Add ServerOptions to initial server startup logs (#794)
### What

Add ServerOptions to initial server startup logs.

![image](https://github.com/hasura/v3-engine/assets/358550/33e49344-a7d8-44be-8bce-b6c8b11a06ec)

### Update

Use json, as well as a span field rather than an event:

![image](https://github.com/hasura/v3-engine/assets/358550/724bcdf4-8125-4a5e-83aa-db7de1229e3a)

V3_GIT_ORIGIN_REV_ID: 28d0c8edd70357b3460a4fbea389f5fa801fd4bf
2024-07-05 08:10:17 +00:00
Daniel Chambers
62e76aac67 Sort open-dds JSON schema for better diffing (#796)
This PR just sorts the definitions in the Open DD JSON schema file, so
that when it changes, we can get better diffs because the types won't
move around inside the file.

V3_GIT_ORIGIN_REV_ID: 80221fae1b4d6e4b98b658f9ba2f19413abf7389
2024-07-05 06:45:45 +00:00
Tom Harding
fa5673cd1f Allow non-nullable variables to fulfil nullable values (#795)
### What

This PR fixes a bug with variable nullability coercion. Specifically,
providing a non-null variable for a nullable field should work, as all
non-nullable variables can be used as nullable variables via "coercion".

Related issues:
* https://hasurahq.atlassian.net/browse/V3ENGINE-243
* https://github.com/hasura/v3-e2e-testing/pull/224 (the test for this
change)

### How

I think someone did something clever with macros, so I tried to unpack
the macro to make sense of it, and in the process, spotted the bug: it's
not that both the location must be nullable AND the variable not, it's
that _if_ the variable is nullable, the location must not be nullable.

V3_GIT_ORIGIN_REV_ID: 4f4ba3fe6898220bbba9ae2867233cd762bef1cb
2024-07-04 16:07:35 +00:00
Varun Choudhary
2723b5d6da console: fix removing of restified endpoint on deleting operation from allowlist
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10917
GitOrigin-RevId: 712fe9a322fa8279a163de740a24ee1948da20c7
2024-07-04 15:55:11 +00:00
Varun Choudhary
7a2fc4e7ee console: fix allow list and rest endpoint issue
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10915
GitOrigin-RevId: 1c2600d1723aa7f19e153e4d489e4f9e0f988fa5
2024-07-04 12:39:52 +00:00
paritosh-08
4b62f7decf release v2024.07.04 (#792)
Update the changelog for new version

---------

Co-authored-by: Anon Ray <ecthiender@users.noreply.github.com>
V3_GIT_ORIGIN_REV_ID: b87f16ebaa1471f010ec461be097bcfd6648c99a
2024-07-04 10:25:48 +00:00
Daniel Chambers
862ad8e0dc Update ndc-models to latest version which includes new name newtypes (#791)
This PR updated ndc-models to the latest version on main. This version
is still a 0.1.x version, but it now includes all the [new
newtypes](https://github.com/hasura/ndc-spec/pull/156) that wrap
previously stringly-typed things. For example, `ArgumentName`,
`FieldName`, etc.

This pervades across the entire engine, but thankfully the changes are
mostly mechanical repetitive changes. Usually you will see conversions
from `String`-typed variables into the newtypes using this sort of form:
`FieldName::from(string.as_str())`, which is the most efficient way
copying the value (the str slice is copied). Or you will see usages of
the newtype as a raw string by `.as_str()`-ing it. Converting the
newtypes into a String can be done with `.into()` if owned, but if
referenced `.as_str().to_owned()` performs the clone and type
conversion.

Other changes:
* A few minor instances of `ok_or()` usages (or similar) have been
converted into lazy error construction variants (eg `ok_or_else()`)

V3_GIT_ORIGIN_REV_ID: 64a371ae6197ef3be98a6f7cdc4052d654a43da0
2024-07-04 08:58:12 +00:00
Rikin Kachhia
8ef7e22ff2 docs: add config reference for disabling native query validation
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10911
GitOrigin-RevId: a604109cb1b56f16a6cdbb16cd237a99ec2eaa30
2024-07-04 08:32:09 +00:00
paritosh-08
08014cab88 pre-execution plugin middleware (#771)
The RFC:
https://docs.google.com/document/d/1NB9fA6J8_dKtWknJkfTiqN5qWhPVDfYVOKFK25gYE7Y/edit

The JIRA: https://hasurahq.atlassian.net/browse/V3ENGINE-234

<!-- The PR description should answer 2 (maybe 3) important questions:
-->

### What

<!-- What is this PR trying to accomplish (and why, if it's not
obvious)? -->

<!-- Consider: do we need to add a changelog entry? -->

This PR adds a new middleware to the `/graphql` endpoint handler. This
new middleware will be used to handle the pre-execution plugins.

### How

<!-- How is it trying to accomplish it (what are the implementation
steps)? -->

We are doing something similar to
https://github.com/tokio-rs/axum/blob/axum-v0.6.20/examples/consume-body-in-extractor-or-middleware/src/main.rs

V3_GIT_ORIGIN_REV_ID: a7e0a7a252efd1f266b3e90df23a8307a9b35fc7
2024-07-03 12:58:26 +00:00
Daniel Chambers
e380876823 Handle multiple ndc-model versions during query planning and execution (#790)
The PR adds code that handles multiple versions of the ndc-models during
the execution pipeline. Depending on whether a connector supports `v01`
or `v02` models, a different set of types is used to send and receive
the http requests.

However, the engine internally still uses the latest (v02) models inside
its IR. Unfortunately, it was going to be quite traumatic to prevent the
engine from using ndc models inside the IR and during response
processing and remote joins. This means that the engine generates v02
requests, and these are downgraded into v01 requests. v01 responses are
upgraded to v02 responses before being processed by the engine.

The ndc client (`execute::ndc::client`) now only takes new wrapper enum
types (`execute::ndc::types`) that split between v01 or v02
requests/responses. Every place that carries an ndc request now carries
this type instead, which allows it to carry either a v01 or a v02
request.

When ndc requests are created during planning, all creation goes via the
new `execute::plan::ndc_request` module. This inspects the connector's
supported version, creates the necessary request, and if needed,
downgrades it to v01.

When ndc responses are read during planning or during remote joins, they
are upgraded to v02 via helper functions defined on the types in
`execute::ndc::types`.

The upgrade/downgrade code is located in `execute::ndc::migration`. Keep
in mind the "v02" types are currently the same as the "v01" types so the
migration code is not doing much. This will change as the v02 types are
modified.

However, this approach has its drawbacks. One is that it prevents
changes to the ndc types [like
this](https://github.com/hasura/ndc-spec/pull/158) without a fair bit of
pain (see
[comment](https://github.com/hasura/ndc-spec/pull/158#issuecomment-2202127094)).
Another is that the downgrade code can fail at runtime and it is not
immediately obvious to developers using new, but unused, v02 features
that their new feature would fail on v01, because that mapping to v01
has already been written. Another is that we're paying some (small,
probably?) performance cost by upgrading/downgrading types because we
need to rebuild data structures.

Also:
* `execute::ndc::response` has been merged into `execute::ndc::client`,
since it was inextricably linked.
V3_GIT_ORIGIN_REV_ID: f3f36736b52058323d789c378fed06af566f39a3
2024-07-03 08:32:37 +00:00
Anon Ray
c1b9592f6b respect relationship comparison capability when generating relationship fields in model filter (#789)
### What

When generating GraphQL schema for relationship fields in model filter,
engine ignores `relation_comparisons` capability of the data connector.
Engine would generate schema for data connectors which don't have this
capability. This PR fixes that.

### How

While generating fields for the filter input type, take the relationship
capabilities into account.

The `ObjectBooleanExpressionType` and `BooleanExpressionType` objects
are quite different, hence their schema generation part is also
different, and is split in two different functions
(`build_comparable_relationships_schema`, and
`build_new_comparable_relationships_schema`). Added checking of
relationship comparison capability in both the functions.

V3_GIT_ORIGIN_REV_ID: dce2b88f7792e01e5bb390ecdb580e223ec80f01
2024-07-02 07:49:10 +00:00
Daniel Harvey
0123c558f1 Enable BooleanExpressionTypes (#783)
<!-- The PR description should answer 2 (maybe 3) important questions:
-->

### What

# BooleanExpressionType

A new metadata kind `BooleanExpressionType` can now be defined. These
can be used in place of `ObjectBooleanExpressionType` and
`DataConnectorScalarRepresentation`, and allow more granular control of
comparison operators and how they are used.

The old metadata types still work, but will eventually be deprecated.

```yaml
kind: BooleanExpressionType
version: v1
definition:
  name: album_bool_exp
  operand:
    object:
      type: Album
      comparableFields:
        - fieldName: AlbumId
          booleanExpressionType: pg_int_comparison_exp
        - fieldName: ArtistId
          booleanExpressionType: pg_int_comparison_exp_with_is_null
        - field: Address
          booleanExpressionType: address_bool_exp
      comparableRelationships:
        - relationshipName: Artist
          booleanExpressionType: artist_bool_exp
  logicalOperators:
    enable: true
  isNull:
    enable: true
  graphql:
    typeName: app_album_bool_exp
```

```yaml
kind: BooleanExpressionType
version: v1
definition:
  name: pg_int_comparison_exp
  operand:
    scalar:
      type: Int
      comparisonOperators:
        - name: equals
          argumentType: String!
        - name: _in
          argumentType: [String!]!
      dataConnectorOperatorMapping:
        - dataConnectorName: postgres_db
          dataConnectorScalarType: String
          operatorMapping:
            equals: _eq
  logicalOperators:
    enable: true
  isNull:
    enable: true
  graphql:
    typeName: app_postgres_int_bool_exp
```

<!-- What is this PR trying to accomplish (and why, if it's not
obvious)? -->

<!-- Consider: do we need to add a changelog entry? -->

### How

Remove feature flag, unhide JsonSchema items, fix a few missing bits of
JsonSchema the tests didn't warn us about before.

<!-- How is it trying to accomplish it (what are the implementation
steps)? -->

V3_GIT_ORIGIN_REV_ID: dd3055d926fdeb7446cd57085679f2492a4358a1
2024-07-01 15:29:14 +00:00
dependabot[bot]
ec59b4e9d3 Bump serde_with from 3.8.1 to 3.8.2 (#785)
V3_GIT_ORIGIN_REV_ID: 4592f1a7fcde9326b7091351c916e710bd5602bc
2024-07-01 15:05:55 +00:00
dependabot[bot]
45f55cf90a Bump serde_json from 1.0.118 to 1.0.119 (#786)
V3_GIT_ORIGIN_REV_ID: ef0c6ab406e71c497e31d26a112083cc5108eeb9
2024-07-01 14:36:18 +00:00
dependabot[bot]
dbda5110f8 Bump clap from 4.5.7 to 4.5.8 (#784)
V3_GIT_ORIGIN_REV_ID: 38de46553688ac1eeae1b364dc9e99c1bcb13fde
2024-07-01 14:08:10 +00:00
Rakesh Emmadi
5efbb09500 Unify get_underlying_type_name and get_base_type functions (#788)
### What
This is a no-op refactor that involves unifying `get_base_type` and
`get_underlying_type_name` functions, whose motives are the same.

### How
Replace the name of erstwhile `get_base_type` fn with
`get_underlying_type_name`. Remove the latter. Update the rest of the
code to use the new function.

V3_GIT_ORIGIN_REV_ID: 0b0d999670641ba265fde153af9b43b4d865e215
2024-07-01 12:57:50 +00:00
Rakesh Emmadi
9e98ed2310 Implement query usage analytics (#713)
JIRA: https://hasurahq.atlassian.net/browse/V3ENGINE-176

This PR implements usage analytics
([RFC](https://docs.google.com/document/d/1k8_ZniiejxHhD0SphtEJ2mg6MoJON0dkk0q4b5WZWDE/edit))
for a GraphQL query when a request is made. The analytics data JSON is
attached to the span, whose details are provided below:
Span name - `execute`
Attribute - `internal.query_usage_analytics = <JSON-string>` OR
`internal.query_usage_analytics_error = <String>`

Refs:
- [Link](https://github.com/hasura/v3-engine/pull/606) to the PR, where
data types for usage analytics were added.
- [Link](https://github.com/hasura/v3-engine/pull/715) to the PR, where
some improvements are made to the analytics data types.

Note: Changelog entry is added.
V3_GIT_ORIGIN_REV_ID: f4089f3354b638533ff72fbec72951e883c31100
2024-07-01 12:10:12 +00:00