Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get variable default values from the query for query plan condition nodes #1640

Merged
merged 17 commits into from
Sep 16, 2022

Conversation

Geal
Copy link
Contributor

@Geal Geal commented Aug 29, 2022

Fix #1603
Blocked on apollographql/federation#2100
Blocked on apollographql/federation#2121
Blocked on #1672
(can't test until that PR is fixed) tested, it works

@github-actions

This comment has been minimized.

@Geal Geal self-assigned this Aug 29, 2022
@Geal Geal added this to the v1.0.0-alpha.1 milestone Aug 30, 2022
@abernix
Copy link
Member

abernix commented Aug 31, 2022

#1666 now tracks 2.1.1 and apollographql/federation-rs#164 is a step in the right direction)

@Geal
Copy link
Contributor Author

Geal commented Sep 1, 2022

once #1672 is merged I'll be able to test that one

@Geal
Copy link
Contributor Author

Geal commented Sep 1, 2022

Now that I added a test, I get this error 🤔 :

{
  "errors": [
    {
      "message": "invalid type for variable: 'if'",
      "locations": [],
      "path": null,
      "extensions": {
        "type": "ValidationInvalidTypeVariable",
        "name": "if"
      }
    }
  ]
}

@abernix abernix self-assigned this Sep 2, 2022
@abernix abernix removed this from the v1.0.0-alpha.1 milestone Sep 2, 2022
@abernix
Copy link
Member

abernix commented Sep 7, 2022

As I noted in the linked issue, all of the blockers above should be in the Router proper now.

@abernix abernix marked this pull request as draft September 7, 2022 11:21
@abernix
Copy link
Member

abernix commented Sep 7, 2022

I'm marking this as a draft just as a precaution, but I think it's ready to be re-evaluated.

@abernix
Copy link
Member

abernix commented Sep 7, 2022

I believe I've fixed merge conflicts and the introduced test is (still) failing as illustrated above, so probably something else to do here, still.

@Geal
Copy link
Contributor Author

Geal commented Sep 13, 2022

so the invalid type for $if is still there: 30f39cf

this feels weird because in the test, it is a Boolean!: https://github.com/apollographql/router/pull/1640/files#diff-0654669b073b6481f538035cfdc0ad46b209207837121627f534ec8c90fa1432R692 and in the spec too: https://github.com/graphql/graphql-spec/pull/742/files#diff-30a69c5a5eded8e1aea52e53dad1181e6ec8f549ca2c50570b035153e2de1c43R2128

and when I set that variable to Boolean (nullable), I get the error thread 'defer_default_variable' panicked at 'defer expects a Boolean! so the variable should be non null too and present or with a default value'

@Geal
Copy link
Contributor Author

Geal commented Sep 13, 2022

@abernix were the blocking issues fixed in the router-bridge release currently used on router main?

@Geal
Copy link
Contributor Author

Geal commented Sep 13, 2022

ok it's coming from the router's variable validation

@abernix
Copy link
Member

abernix commented Sep 13, 2022

@abernix were the blocking issues fixed in the router-bridge release currently used on router main?

Yup, they were. Seems like you found what I eventually found but didn't have a chance to dig into. Thanks! 😄

@Geal Geal requested review from garypen and bnjjj September 13, 2022 10:38
@Geal
Copy link
Contributor Author

Geal commented Sep 13, 2022

I'm re-requesting reviews because there's an additional fix for default variable value validation

@Geal Geal marked this pull request as ready for review September 13, 2022 12:11
@Geal Geal mentioned this pull request Sep 13, 2022
@Geal Geal enabled auto-merge (squash) September 16, 2022 08:21
@Geal Geal disabled auto-merge September 16, 2022 08:21
@Geal Geal enabled auto-merge (squash) September 16, 2022 08:22
@Geal Geal merged commit be64832 into main Sep 16, 2022
@Geal Geal deleted the geal/default-variables branch September 16, 2022 08:32
@abernix abernix mentioned this pull request Sep 16, 2022
o0Ignition0o pushed a commit that referenced this pull request Sep 16, 2022
> **Note**
> We're almost to 1.0! We've got a couple relatively small breaking
changes to the configuration for this release (none to the API) that
should be relatively easy to adapt to and a number of bug fixes and
usability improvements.

## ❗ BREAKING ❗

### Change `headers` propagation configuration ([PR
#1795](#1795))

While it wasn't necessary today, we want to avoid a necessary breaking
change in the future by proactively making room for up-and-coming work.
We've therefore introduced another level into the `headers`
configuration with a `request` object, to allow for a `response` (see
[Issue #1284](#1284)) to
be an _additive_ feature after 1.0.

A rough look at this should just be a matter of adding in `request` and
indenting everything that was inside it:

```patch
headers:
    all:
+     request:
          - remove:
              named: "test"
```

The good news is that we'll have `response` in the future! For a full
set of examples, please see the [header propagation
documentation](https://www.apollographql.com/docs/router/configuration/header-propagation/).

By @bnjjj in #1795

### Bind the Sandbox on the same endpoint as the Supergraph, again
([Issue #1785](#1785))

We have rolled back an addition that we released in this week's
`v1.0.0-rc.0` which allowed Sandbox (an HTML page that makes requests to
the `supergraph` endpoint) to be on a custom socket. In retrospect, we
believe it was premature to make this change without considering the
broader impact of this change which ultimately touches on CORS and some
developer experiences bits. Practically speaking, we may not want to
introduce this because it complicates the model in a number of ways.

For the foreseeable future, Sandbox will continue to be on the same
listener address as the `supergraph` listener.

It's unlikely anyone has really leaned into this much already, but if
you've already re-configured `sandbox` or `homepage` to be on a custom
`listen`-er and/or `path` in `1.0.0-rc.0`, here is a diff of what you
should remove:

```diff
sandbox:
-  listen: 127.0.0.1:4000
-  path: /
  enabled: false
homepage:
-  listen: 127.0.0.1:4000
-  path: /
  enabled: true
```

Note this means you can either enable the `homepage`, or the `sandbox`,
but not both.

By @o0Ignition0o in #1796

## 🚀 Features

### Automatically check "Return Query Plans from Router" checkbox in
Sandbox ([Issue
#1803](#1803))

When loading Sandbox, we now automatically configure it to toggle the
"Request query plans from Router" checkbox to the enabled position which
requests query plans from the Apollo Router when executing operations.
These query plans are displayed in the Sandbox interface and can be seen
by selecting "Query Plan Preview" from the drop-down above the panel on
the right side of the interface.

By @abernix in #1804

## 🐛 Fixes

### Fix `--dev` mode when no configuration file is specified ([Issue
#1801](#1801)) ([Issue
#1802](#1802))

We've reconciled an issue where the `--dev` mode flag was being ignored
when running the router without a configuration file. (While many use
cases do require a configuration file, the Router actually doesn't
_need_ a confguration in many cases!)

By @bnjjj in #1808

### Respect `supergraph`'s `path` for Kubernetes deployment probes
([Issue #1787](#1787))

If you've configured the `supergraph`'s `path` property using the Helm
chart, the liveness
and readiness probes now utilize these correctly. This fixes a bug where
they continued to use the _default_ path of `/` and resulted in a
startup failure.

By @damienpontifex in #1788

### Get variable default values from the query for query plan condition
nodes ([PR #1640](#1640))

The query plan condition nodes, generated by the `if` argument of the
`@defer` directive, were
not using the default value of the variable passed in as an argument.

This _also_ fixes _default value_ validations for non-`@defer`'d
queries.

By @Geal in #1640

### Correctly hot-reload when changing the `supergraph`'s `listen`
socket ([Issue
#1814](#1814))

If you change the `supergraph`'s `listen` socket while in `--hot-reload`
mode, the Router will now correctly pickup the change and bind to the
new socket.

By @o0Ignition0o in #1815

## 🛠 Maintenance

### Improve error message when querying non existent field [Issue
#1816](#1816)

When querying a non-existent field you will get a better error message:

```patch
{
  "errors": [
    {
-       "message": "invalid type error, expected another type than 'Named type Computer'"
+       "message": "Cannot query field \"xxx\" on type \"Computer\""
    }
  ]
}
```

By @bnjjj in #1817

### Update `apollo-router-scaffold` to use the published `apollo-router`
crate [PR #1782](#1782)

Now that `apollo-router` is released on
[crates.io](https://crates.io/crates/apollo-router), we have updated the
project scaffold to rely on the published crate instead of Git tags.

By @o0Ignition0o in #1782

### Refactor `Configuration` validation [Issue
#1791](#1791)

Instantiating `Configuration`s is now fallible, because it will run
consistency checks on top of the already run structure checks.

By @o0Ignition0o in #1794

### Refactor response-formatting tests
[#1798](#1798)

Rewrite the response-formatting tests to use a builder pattern instead
of macros and move the tests to a separate file.

By @Geal in #1798

## 📚 Documentation

### Add `rustdoc` documentation to various modules ([Issue
#799](#799))

Adds documentation for:

- `apollo-router/src/layers/instrument.rs`
- `apollo-router/src/layers/map_first_graphql_response.rs`
- `apollo-router/src/layers/map_future_with_request_data.rs`
- `apollo-router/src/layers/sync_checkpoint.rs`
- `apollo-router/src/plugin/serde.rs`
- `apollo-router/src/tracer.rs`

By @garypen in #1792

### Fixed `docs.rs` publishing error from our last release

During our last release we discovered for the first time that our
documentation wasn't able to compile on the [docs.rs](https://docs.rs)
website, leaving our documentation in a [failed
state](https://docs.rs/crate/apollo-router/1.0.0-rc.0/builds/629200).

While we've reconciled _that particular problem_, we're now being
affected by
[this](https://docs.rs/crate/router-bridge/0.1.7/builds/629895) internal
compiler errors (ICE) that [is
affecting](rust-lang/rust#101844) anyone using
`1.65.0-nightly` builds circa today. Since docs.rs uses `nightly` for
all builds, this means it'll be a few more days before we're published
there.

With thanks to @SimonSapin in
apollographql/federation-rs#185

Co-authored-by: Coenen Benjamin <benjamin.coenen@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

query plan condition nodes do not use default values of variables
4 participants