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

feat: use new GraphQL Config #1342

Merged
merged 2 commits into from
Feb 16, 2020
Merged

feat: use new GraphQL Config #1342

merged 2 commits into from
Feb 16, 2020

Conversation

acao
Copy link
Member

@acao acao commented Feb 16, 2020

re-created @ardatan's #1225 PR, as things got kinda tricky post typescript migration and removing the watchman


  • Use new GraphQL Config
  • Remove extra endpoint extension

About endpoint

In new GraphQL Config, there is no extension called endpoint so all sources of schema are defined as schema in GraphQL Config file.

Related #1204 (comment) and #1191

This alpha version of GraphQL Config supports GraphQL-js v15. We're testing our graphql-toolkit which has core logic in the CLI for both v14 and v15 in the CI.
https://github.com/ardatan/graphql-toolkit/pull/403/checks?check_run_id=387927623

Related #920

Also user can add their own custom schema loaders in two different ways;

schema:
    - your-own-schema-pointer:
         loader: my-loader#loaderFn

or the developer can add their loaders in the library code;

const MyOwnExtension: GraphQLExtensionDeclaration = api => {
  // Schema
  api.loaders.schema.register(new CodeFileLoader());
  api.loaders.schema.register(new GitLoader());
  api.loaders.schema.register(new GithubLoader());
  api.loaders.schema.register(new ApolloEngineLoader());
  api.loaders.schema.register(new PrismaLoader());

  // Documents
  api.loaders.schema.register(new CodeFileLoader());

  return {
    name: 'my-own-extension',
  };
};
const config = await loadConfig({ extensions: [MyOwnExtension]});

More info; https://graphql-config.com/docs/loaders'

Related #1118

Let's say you have some custom extensions in your configuration file;

schema: some-schema-pointer.graphql
extensions:
   my-own-extension:
       myOwnField: true

You can get like below

const { myOwnField } = config.get('my-own-extension');

@acao acao added this to In progress in 3. Complete LSP Features via automation Feb 16, 2020
@acao acao changed the title fix: use new GraphQL Config feat: use new GraphQL Config Feb 16, 2020
@acao acao mentioned this pull request Feb 16, 2020
2 tasks
@acao
Copy link
Member Author

acao commented Feb 16, 2020

so excited about these new features! feels like so much is possible. thanks for all this @ardatan and @Urigo. let me know when you all go stable but there's no rush, as you'll likely have 3.0.0 stable well before we are making stable releases again

@acao acao merged commit e45838f into master Feb 16, 2020
3. Complete LSP Features automation moved this from In progress to Done Feb 16, 2020
@github-actions github-actions bot deleted the graphql-config branch February 16, 2020 18:55
@Urigo
Copy link
Collaborator

Urigo commented Feb 16, 2020

That's awesome! thank you @acao !
We'll get you a stable version this week!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants