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

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

Merged
merged 7 commits into from
Oct 1, 2019

Conversation

JakeDawkins
Copy link
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
 - 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
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.

None yet

2 participants