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

[apollo-language-server] Allow config.client.service.localSchemaFile #676

Merged
merged 2 commits into from
Nov 10, 2018

Conversation

stnwk
Copy link
Contributor

@stnwk stnwk commented Nov 8, 2018

Imagine the following apollo.config.js:

module.exports = {
  client: {
    service: {
      name: 'My Application',
      localSchemaFile: './src/schema.json',
    },
  },
};

This config comes from the following situation:

  • You cannot provide an api endpoint for some reasons (maybe auth, whatever)
  • However, you have the necessary schema.json locally

Currently, this is not possible.
This PR fixes this.

@stnwk
Copy link
Contributor Author

stnwk commented Nov 8, 2018

No idea what's wrong with circleci though 🤔

@stnwk
Copy link
Contributor Author

stnwk commented Nov 10, 2018

@martijnwalraven Can you take a look at this and give me a hint whether this is moving in the right direction? Thanks :)

@martijnwalraven
Copy link
Contributor

@stnwk Yes, sorry, I had pushed a fix for the getServiceName issue before I saw this, so it needs to be rebased. (The CI issues should be fixed.)

Using FileSchemaProvider is exactly what that was meant for, but we'll need to decide on the config format. I suspect we'll want to nest localSchemaFile under service instead of directly under client, but I'd like to get @jbaxleyiii's take on that as well.

@stnwk
Copy link
Contributor Author

stnwk commented Nov 10, 2018

@martijnwalraven @jbaxleyiii

Thanks for your input! You're right: Nesting localSchemaFile under client.service seems more accurate to me as well.

I rebased and updated my code to support the following config:

module.exports = {
  client: {
    service: {
      name: 'My Application',
      localSchemaFile: './src/schema.json',
    },
  },
};

I have also updated the README to include an example of this config and be more detailed about it.

@stnwk stnwk changed the title [apollo-language-server] Allow config.client.localSchemaFile [apollo-language-server] Allow config.client.service.localSchemaFile Nov 10, 2018
@martijnwalraven martijnwalraven merged commit d348b58 into apollographql:master Nov 10, 2018
@martijnwalraven
Copy link
Contributor

Thanks, merged from 10000m altitude!

@tsaiDavid
Copy link

Thanks @stnwk - needed the localSchemaFile option, but I'm seeing the following error from my Apollo VSCode plugin's output:

(node:93814) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'schemaTags' of null

(node:93814) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@stnwk
Copy link
Contributor Author

stnwk commented Nov 12, 2018

@tsaiDavid I'm not sure this is related. Can you open up a new issue with a more detailed description? Maybe also include what your schema file looks like and your full apollo.config.js

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.

apollo-vscode: Cannot use local schema file
3 participants