Skip to content

Support federated service:check/push with local schema file#1489

Merged
JakeDawkins merged 7 commits intomasterfrom
jake/sdl-federation-checks
Oct 1, 2019
Merged

Support federated service:check/push with local schema file#1489
JakeDawkins merged 7 commits intomasterfrom
jake/sdl-federation-checks

Conversation

@JakeDawkins
Copy link
Copy Markdown
Contributor

@JakeDawkins JakeDawkins commented Aug 27, 2019

Right now, the only way to push/check a federated service is to use the --endpoint option and query the _service { sdl }. This is difficult to do in CI workflows because of other dependencies services may need in order to start up.

This PR adds the ability to specify a --localSchemaFile to use as a source of the sdl instead of querying a running service.

Constraints

  • right now, the localSchemaFile must be a graphql file. The file used is interpreted as plain text and it passed directly to the check/push mutation, so anything file extensions other than graphql, gql, and graphqls will be errored.
    • We can't use a ts/js file, because we'd have to enforce a standard export name (or have it be the default export)
    • We can't use introspection json output, since theoretically at least the sdl with all federation directives wouldn't be able to be introspected properly.

Other

  • Since sdl is now the only thing that's being queried from running services instead of the url and name, the federation-info providers aren't needed. The logic for loading the sdl can fit inside the existing schema providers.
  • Renamed the introspection schema provider to endpoint since now there's more being fetched from an endpoint than the introspection query (_service { sdl })

usage

For the CLI, you can now use the --localSchemaFile flag to point to sdl

Screen Shot 2019-08-27 at 1 08 06 PM

You can also add the file path in the config file to avoid using the flag

module.exports = {
  service: {
    name: 'JakeDawkins-1503',
    localSchemaFile: './src/schema.graphql'
  },
};

Along with client projects, the localSchemaFile also supports multiple values

In the apollo config file:

module.exports = {
  service: {
    name: 'JakeDawkins-1503',
    localSchemaFile: ['./src/schema.graphql', './src/schema2.graphql']
  },
};

as a CLI flag:

--localSchemaFile=schema.graphql,schema2.graphql

Screen Shot 2019-08-27 at 1 09 19 PM

TODO:

  • Update CHANGELOG.md* with your change (include reference to issue & this PR)
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass

*Make sure changelog entries note which project(s) has been affected. See older entries for examples on what this looks like.

@JakeDawkins JakeDawkins added 🔨 cli related to the CLI itself 🎉 feature New addition or enhancement to existing solutions 💻 component - language-server labels Aug 27, 2019
@JakeDawkins JakeDawkins marked this pull request as ready for review August 28, 2019 14:02
@JakeDawkins JakeDawkins changed the title [WIP] Run service:check and push with local schema file Run service:check and push with local schema file Aug 28, 2019
@JakeDawkins JakeDawkins changed the title Run service:check and push with local schema file Support federated service:check/push with local schema file Aug 28, 2019
@JakeDawkins JakeDawkins force-pushed the jake/sdl-federation-checks branch 3 times, most recently from 41ba7d9 to f8f8c3a Compare September 16, 2019 13:12
@JakeDawkins JakeDawkins force-pushed the jake/sdl-federation-checks branch from 1b6c2a6 to 192152e Compare September 17, 2019 16:46
 - apollo-codegen-core@0.36.0-alpha.0
 - apollo-codegen-flow@0.34.0-alpha.0
 - apollo-codegen-scala@0.35.0-alpha.0
 - apollo-codegen-swift@0.36.0-alpha.0
 - apollo-codegen-typescript@0.36.0-alpha.0
 - apollo-language-server@1.16.0-alpha.0
 - apollo@2.19.0-alpha.0
 - vscode-apollo@1.11.0-alpha.0
@JakeDawkins JakeDawkins force-pushed the jake/sdl-federation-checks branch from 30419c4 to e0fb3c0 Compare October 1, 2019 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 component - language-server 🔨 cli related to the CLI itself 🎉 feature New addition or enhancement to existing solutions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants