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

Generate composite schema in spec'd form #305

Closed
wants to merge 65 commits into from
Closed

Conversation

queerviolet
Copy link
Contributor

@queerviolet queerviolet commented Dec 19, 2020

Update the composer's printer to generate a composite schema that follows the current draft spec.

This PR was based on:

Note

#559 is meant to supersede this.

trevor-scheer and others added 22 commits November 11, 2020 08:35
This commit cuts the gateway over to relying solely on
the `composedSdl` output from composition. This unlocks
the ability for either a user or Apollo Studio to serve
the gateway CSDL instead of each SDL file per service.

This is fairly straightforward, as `schema` was only
depended on in one place by query plan execution, during
the final pass of graphql-js `execute()`. Instead, we now
construct a `GraphQLSchema` ourselves from the CSDL. This
comes with a caveat: the schema we're creating doesn't have
all of the annotations that once existed in the schema that
we were using from `composeAndValidate()`. However, this is
inconsequential for the way the schema is currently being
used during the final execution pass.
This commit reverts e93d8d4, which was once
necessary (as its own description notes) for Node.js 6, which is no longer
a supported runtime of this package (it is far outside Node.js LTS support).
* Uses a `harmonizer-js` which is a Rollup-able library that produces the
  IIFE.
* Uses a library called `harmonizer` which invokes the IIFE via Deno's
  wrapper for V8.
* Binary called `compose` invokes the `harmonizer` lib.
* `build.rs` script that takes care of invoking the TypeScript compilation
  as well as the Rollup packing.
federation-js/src/csdlDefinitions.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,32 @@
export default `
directive @cs__key(graph: cs__Graph!)
repeatable on FRAGMENT_DEFINITION
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going forward with using fragment defs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are… trying it. part of the point of this PR is to get the whole repo into a shape where we can try it, hate it, change it, and be able to propagate those changes through the codebase without manually changing test fixtures

@@ -0,0 +1,32 @@
export default `
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting that there may be value in exporting the defs for each of these individually as well as a default export which combines all of them into the same document as they are now. Only speculating, so take this with a grain of salt.

provides: cs__SelectionSet)
on FIELD_DEFINITION

directive @cs__error(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have multiple errors at a single location potentially? repeatable?

federation-js/src/service/printComposedSdl.ts Outdated Show resolved Hide resolved
printFederationTypeDirectives(type) +
printFields(options, type)
printFields(options, type) +
printKeys(type)
);
}

// Federation change: print usages of the @owner and @key directives.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update comment

// print(composed.composedSdl);
// }

done(composed.errors ? { Err: composed.errors } : { Ok: composed.composedSdl })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, something running this file is putting done and composition in scope?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it's injected in lib.rs

stargate/crates/query-planner/build.rs Outdated Show resolved Hide resolved
@@ -22,6 +20,8 @@ directive @provides(fields: String!) on FIELD_DEFINITION

directive @requires(fields: String!) on FIELD_DEFINITION

directive @using(spec: String!) on SCHEMA
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be repeatable, yeah?

@queerviolet queerviolet marked this pull request as ready for review February 11, 2021 15:25
@abernix abernix self-assigned this Feb 11, 2021
abernix added a commit that referenced this pull request Mar 2, 2021
While this package was added to the `package.json` in the PR this implementation was extracted from in #305, it does not appear to be actually used in the `rollup.config.js`.
@abernix abernix marked this pull request as draft March 2, 2021 15:42
@abernix
Copy link
Member

abernix commented Mar 10, 2021

#559 is meant to supersede this.

@abernix
Copy link
Member

abernix commented Apr 1, 2021

Superseded by #588 and landed within #622. There are portions of this PR that didn't land, but we can restore that branch here on this PR when the time is right.

@abernix abernix closed this Apr 1, 2021
@abernix abernix deleted the qv/implement-cs branch November 8, 2022 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants