Commit Graph

338 Commits

Author SHA1 Message Date
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
dependabot[bot]
92bafb34ec Bump proc-macro2 from 1.0.84 to 1.0.85 (#657)
V3_GIT_ORIGIN_REV_ID: ca07fe0608405a5839d36f9c8e1779b9640c2a6c
2024-06-03 07:33:38 +00:00
dependabot[bot]
fda09a2353 Bump thiserror from 1.0.58 to 1.0.61 (#655)
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.58 to
1.0.61.

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Anon Ray <ecthiender@users.noreply.github.com>
V3_GIT_ORIGIN_REV_ID: d40b15640ffddfc9faf6d8c3827ffaa6a7690280
2024-06-03 06:51:49 +00:00
dependabot[bot]
1e29a6de72 Bump tokio from 1.36.0 to 1.38.0 (#656)
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.36.0 to 1.38.0.

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: 46e947ffdc4dc572cf2d364da24bbfb2a5aad1a0
2024-06-03 06:37:58 +00:00
Philip Lykke Carlsen
812f44f3c1 SDL schema generation improvements (#642)
Add the ability to render field input-arguments and default values in
sdl.

Also add a small CLI tool to help inspect the GraphQL schemas that
result from a piece of engine metadata.

V3_GIT_ORIGIN_REV_ID: ddb7315f12d24eafbf57782f37f840ca44d94789
2024-06-01 06:42:03 +00:00
Gil Mizrahi
6964b7cf3d add filter expressions for Album and Artist schemas for ndc-postgres (#643)
## Description

I want to be able to use a `where` clause for Artists and Albums when
running v3-engine with the tests ndc-postgres schema.

V3_GIT_ORIGIN_REV_ID: 50824decb794f41f745268e7ca297a5a1c04c808
2024-05-31 15:52:37 +00:00
Samir Talwar
02ee05bed4 Merge match branches to reduce duplication. (#649)
V3_GIT_ORIGIN_REV_ID: 69b2e0a370c547aed9ed798fa54168bc67f98569
2024-05-31 14:44:11 +00:00
Samir Talwar
c80ab33726 Allow arbitrary arguments to the justfile test commands. (#650)
Sometimes you just want to run a specific test.

The arguments are passed straight to the test runner: `cargo nextest` if
you have it installed, and `cargo test` if you do not. These accept
different arguments so the user will need to know which one they are
using.

V3_GIT_ORIGIN_REV_ID: 9cd6f9d770899e0bb3aa4537008eedba052818d7
2024-05-31 14:11:21 +00:00
Samir Talwar
dfccac348e Use Clippy to help simplify conditions. (#648)
Just because it's fewer lines of code.

1. Invert `if`/`else` blocks with negative conditions.
2. Unwrap redundant `else` blocks.
3. Simplify a few branches to `let … else`.
4. Replace a `match` with `if let`.

V3_GIT_ORIGIN_REV_ID: 4f10730b688d21c1fc86a45ee5fb4adf008b3d94
2024-05-31 13:02:00 +00:00
Samir Talwar
051b016f46 Avoid cloning headers when making an NDC request if possible. (#646)
Sometimes they will be borrowed and therefore must be cloned, but
sometimes they'll be owned, and we can use that.

V3_GIT_ORIGIN_REV_ID: 99f40f303c42acc0f44e4ce3081a1c9dce1802b1
2024-05-31 11:01:00 +00:00
Samir Talwar
11e1e02d59 Store NDC capabilities in the resolved metadata. (#641)
## Description

This avoids a query to `/capabilities` when explaining.

## 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
- [ ] bugfix
- [x] 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 engine no longer makes a request to NDC capabilities when explaining
a query or mutation, instead using the stored capabilities from the
build.

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

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

V3_GIT_ORIGIN_REV_ID: f38867e0f5a832c45a857c5e58d7a44c1c05d71f
2024-05-30 17:42:56 +00:00
Daniel Harvey
c09a6ee6c6 Add a DataConnectorColumnName newtype (#639)
<!-- Thank you for submitting this PR! :) -->

## Description

Once again I found myself getting confused as to what a `String` meant
so I wrapped it up in a newtype and then found a bug and fixed it as a
result.

(nearly) 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)_

- [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
-->

Use field mappings more consistently when following remote joins.

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

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

V3_GIT_ORIGIN_REV_ID: dd4fff5c4c8f5d1e50742c046b62cb7ddec3f467
2024-05-30 14:50:47 +00:00
Rakesh Emmadi
f04bdc59d7 expose traceresponse header in CORS (#644)
The
[traceresponse](https://w3c.github.io/trace-context/#traceresponse-header)
header needs to be exposed over CORS request's so that clients can
retrieve for further processing. We emit this response header to
represent tracecontext.

ref
[this](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers)
for more info

V3_GIT_ORIGIN_REV_ID: 7944c764343b201b37a635acfb927910202784ad
2024-05-30 14:28:11 +00:00
Samir Talwar
835668b03c Avoid cloning data connector URL and headers. (#635)
We don't need to clone to populate the transient
`ndc_client::Configuration` type.

V3_GIT_ORIGIN_REV_ID: 920f1a2a82d45fb51179126347aa3d9ba05a6b1f
2024-05-30 11:34:05 +00:00
Daniel Harvey
10d521bfcb Removed unused field (#637)
<!-- Thank you for submitting this PR! :) -->

## Description

This doesn't do anything. Functional no-op.

V3_GIT_ORIGIN_REV_ID: 4a9e35bae95ef3bf9c11de6d15f93031d0976311
2024-05-30 09:45:51 +00:00
Anon Ray
dd2e2847d3 move serializable http types to a separate module (#633)
## Description

We use few HTTP types (URL, http header name, value, header map etc.) in
the resolved metadata, which needs to be serialized. We have newtype
wrappers around them to implement serialization/deserialization.

This PR moves them to a separate helper module.

And also introduces a new type `SerializableHeaderName` which is
required in an upcoming PR of forwarding request headers to NDC.

Functional no-op.

V3_GIT_ORIGIN_REV_ID: 4f907a652a9826bc52996fa37d2a7590f24ee30a
2024-05-30 08:05:13 +00:00
Samir Talwar
79074bef84 Idiomatic iteration patterns. (#632)
Fix some warnings flagged by Clippy.

1. Elide `.into_iter()` where it's unnecessary.
2. Favor `&` over `.iter()`.
3. Use `.values()` on maps instead of discarding keys by destructuring.
4. Avoid `::from_iter(…)` in favor of `.collect()`.

I also replaced a call to `.cloned()` with `.copied()`.

V3_GIT_ORIGIN_REV_ID: 7d39665b0cd04f5bae9405c0ff5f044f57433f32
2024-05-30 06:22:45 +00:00
Daniel Harvey
8238613e68 Use OperatorName newtype (#631)
Got confused by more `String` types, turns out we already had more
accurate types for these things. Functional no-op.

V3_GIT_ORIGIN_REV_ID: a9c73024ab23233a73934bb2cd3741b3b4d7a378
2024-05-29 19:36:26 +00:00
Daniel Harvey
7bc6755686 Use DataConnectorScalarType everywhere (#628)
<!-- Thank you for submitting this PR! :) -->

## Description

In https://github.com/hasura/v3-engine/pull/599 we added new
`BooleanExpressionType` to OpenDD. It included a number of helpful
newtypes such as `DataConnectorScalarType` that replace uses of raw
string and make intent inside engine code easier to follow. This change
uses that newtype everywhere in `metadata-resolve`.

<!--
  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
-->

Use `DataConnectorScalarType` string newtype internallly and in OpenDD
types.

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

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

V3_GIT_ORIGIN_REV_ID: b44709f39b30f25908106110f62c72e3d13b4eb6
2024-05-29 09:55:27 +00:00
Tom Harding
18af80097e Deprecate supergraph configuration in the metadata (#624)
<!-- Thank you for submitting this PR! :) -->

## Description

With #614 sorted, V2 metadata is now forward compatible with the engine.
This PR therefore adds a V3 of the metadata: V2 without the supergraph
field.

- [APG-115](https://hasurahq.atlassian.net/browse/APG-115)

## Changelog

### Product

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

### Type

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

### Changelog entry

A version 3 of the metadata configuration schema has been published. All
configuration in the top-level `supergraph` field should now be placed
within a subgraph (e.g. a `globals` subgraph).

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

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

[APG-115]:
https://hasurahq.atlassian.net/browse/APG-115?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

V3_GIT_ORIGIN_REV_ID: 323320ed3c37586cd7779bce293075b9ecdad515
2024-05-28 13:53:05 +00:00
Anon Ray
543ffd4727 data shape for query usage analytics (#606)
## Description

The expectation is, that engine should emit usages of OpenDD objects
(i.e. models, commands, relationships, permissions, fields of types
etc.) from a GraphQL query.

This PR adds the types required to gather query usage analytics, under a new crate `query-usage-analytics`.

V3_GIT_ORIGIN_REV_ID: 49778c25a9019e0c8c9a2d13eaa8ba28638b8b55
2024-05-28 09:51:09 +00:00
Samir Talwar
4c3bcb882e Lint tests too, and suppress some warnings. (#622)
`test_each::path` always gives us a `PathBuf` even if we don't want one,
so we need to suppress the associated warning.

V3_GIT_ORIGIN_REV_ID: 4f2bb29122df6979ad378227fb88e4632d3551f7
2024-05-28 08:51:37 +00:00
Samir Talwar
ecfe7f81d9 Do not install unused tools in the release Dockerfile. (#621)
This speeds up the build considerably when building from scratch.

V3_GIT_ORIGIN_REV_ID: 1ef1315b5b3b56862ec7ed52c951ffc5a4706738
2024-05-28 06:59:57 +00:00
Daniel Chambers
a132759dac Fixed arbitrary ordering of directions in GraphqlConfig causing error (#625)
## Description
If the user specified their orderings in their GraphqlConfig in a
different order, they would be presented with an error.

```yaml
enumTypeNames:
  - directions: # Reversed ordering of this list
      - Desc
      - Asc
    typeName: OrderBy
```

> ERR Code=opendds-validation Message="invalid metadata: error building
schema: unable to build schema: metadata is not consistent: invalid
directions: Desc,Asc defined in orderByInput of GraphqlConfig ,
currenlty there is no support for partial directions. Please specify a
type which has both 'asc' and 'desc' directions"
7:56PM ERR Supergraph Build failed.

This has been fixed.

## Changelog

### 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
-->

Fixed arbitrary ordering of directions in GraphqlConfig causing invalid
error

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

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

V3_GIT_ORIGIN_REV_ID: b27a0dd3b5c665f54ea58a40af8b2b1bfb0d2434
2024-05-28 05:43:48 +00:00
Tom Harding
01711c20da Explicitly remap the supergraph config (#614)
## Description

With #613 merged, it is safe to create an `__globals` subgraph into
which we can sort all supergraph config. This PR gives supergraph
objects a qualified name (using the `__globals` subgraph). Note that
outside of debugging/tracing, this is functionally a no-op: we strip the
subgraph from the objects as soon as we use them, because the global
nature of the config means that this is irrelevant information.

<!--
  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

### 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
- [ ] bugfix
- [x] 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
-->

Metadata config declared under the `supergraph` field will now appear as
part of an `__globals` subgraph in tracing. Note that the field can also
be omitted and the config placed in a user-named subgraph.

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

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

V3_GIT_ORIGIN_REV_ID: 84d2beed98f843df246c8562188cdf7de63643fc
2024-05-27 18:44:33 +00:00
paritosh-08
9546362b2e fix a minor typing mistake (#623)
currenlty -> currently

Slack: https://hasurahq.slack.com/archives/C066TKMH79R/p1716816424823129
V3_GIT_ORIGIN_REV_ID: 5897079c2b942bca4d74cc84d868f4340ce6e762
2024-05-27 14:50:48 +00:00
Rakesh Emmadi
da27c29ee8 Use Exists expression for relationship predicates in permissions (#612)
A follow-up to https://github.com/hasura/v3-engine/pull/605.

Similar to the above linked PR, apply the `Exists` NDC expression to all
relationship predicates in permission filters. This avoids tracking
relationship paths and their usage in comparison targets.

V3_GIT_ORIGIN_REV_ID: 09784b7ea04f054f2183e593da6e6cc327a5c853
2024-05-27 12:48:40 +00:00
Tom Harding
e4c5d7a752 Add the SubgraphIdentifier type (#613)
## Description

Parallel to #611, in service of removing supergraph config, we'd like to
map all current supergraph config into a generated subgraph. To ensure
that we don't end up with an unfortunate naming collision, I've decided
to refine the definition of a subgraph identifier to exclude any string
starting with `__internal`, which we can then have as our "internal
namespace". This change introduces the new type, and updates the
"unknown_namespace" subgraph to come under this umbrella.

This change should be a no-op to any user who hasn't used a subgraph
name prefixed with `__internal`.

<!--
  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

User-defined subgraphs may no longer be given names that start with
`__internal`, as this will be reserved for internally generated
subgraphs.

- 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
- [ ] bugfix
- [x] 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
-->

User-defined subgraphs may no longer have names that start with
`__internal`.

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

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

V3_GIT_ORIGIN_REV_ID: a6df1bba7b1f2cda4593654c15d168f25b7134b2
2024-05-27 10:06:42 +00:00
dependabot[bot]
0b16216bad Bump anyhow from 1.0.82 to 1.0.86 (#617)
V3_GIT_ORIGIN_REV_ID: b5611a05dd14177ed1391edffa84dc8c82a355c6
2024-05-27 07:54:46 +00:00
dependabot[bot]
29f64ad5a8 Bump proc-macro2 from 1.0.81 to 1.0.84 (#616)
V3_GIT_ORIGIN_REV_ID: 99f387f6fade155355789e9b7ae57ee8407358a2
2024-05-27 07:29:57 +00:00