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

Error using schema:publish with local .graphql schema file #672

Closed
aergonaut opened this issue Nov 8, 2018 · 10 comments
Closed

Error using schema:publish with local .graphql schema file #672

aergonaut opened this issue Nov 8, 2018 · 10 comments
Assignees

Comments

@aergonaut
Copy link

I am trying to publish my GraphQL schema to Apollo Engine with the apollo schema:publish command. According to the docs, I should be able to give --endpoint the path to a local .graphql file that contains my schema. However, when I try to do this, the command errors:

$ apollo schema:publish --endpoint=schema.graphql --key="REDACTED"
 ✔ Loading Apollo Project
 ✖ Uploading service to Engine
   → Only absolute URLs are supported
TypeError: Only absolute URLs are supported
    at getNodeRequestOptions (~/.nvm/versions/node/v9.11.2/lib/node_modules/apollo/node_modules/node-fetch/lib/index.js:1265:9)
    at ~/.nvm/versions/node/v9.11.2/lib/node_modules/apollo/node_modules/node-fetch/lib/index.js:1335:19
    at new Promise (<anonymous>)
    at fetch (~/.nvm/versions/node/v9.11.2/lib/node_modules/apollo/node_modules/node-fetch/lib/index.js:1332:9)
    at ~/.nvm/versions/node/v9.11.2/lib/node_modules/apollo/node_modules/apollo-link-http/lib/bundle.umd.js:91:17
    at new Subscription (~/

My GraphQL API is authenticated, so I can't point apollo directly at the endpoint as it won't have authentication. I was able to get around this by running my server locally and removing the authentication guards from the API endpoint, but I don't think that's a good long-term approach.

@Alahel
Copy link

Alahel commented Nov 9, 2018

I am also facing the same issue here :

2018-11-09T13:24:40.443Z - ERROR - command:engine:upload - Error: Command failed: apollo schema:publish --endpoint="/myAbsolutePath/front-end/src/config/schema.json" --key="XXX"
TypeError: Only absolute URLs are supported
    at getNodeRequestOptions (~/Documents/moviepro/api/node_modules/apollo-env/node_modules/node-fetch/lib/index.js:1265:9)
    at ~/Documents/moviepro/api/node_modules/apollo-env/node_modules/node-fetch/lib/index.js:1335:19
    at new Promise (<anonymous>)
    at fetch (~/Documents/moviepro/api/node_modules/apollo-env/node_modules/node-fetch/lib/index.js:1332:9)
    at ~/Documents/moviepro/api/node_modules/apollo-link-http/lib/bundle.umd.js:91:17
    at new Subscription (~/Documents/moviepro/api/node_modules/zen-observable/lib/Observable.js:179:34)
    at Observable.subscribe (~/Documents/moviepro/api/node_modules/zen-observable/lib/Observable.js:258:14)
    at ~/Documents/moviepro/api/node_modules/apollo-link/lib/bundle.umd.js:64:24
    at new Promise (<anonymous>)
    at Object.toPromise (~/Documents/moviepro/api/node_modules/apollo-link/lib/bundle.umd.js:63:16)

    at ChildProcess.exithandler (child_process.js:276:12)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:915:16)
    at Socket.stream.socket.on (internal/child_process.js:336:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:561:12)

@flippidippi
Copy link

Same here. I'm writing the schema to a json file using graphqlSync because the endpoint is authenticated but I can't get the CLI to read the file.

@Alahel
Copy link

Alahel commented Nov 14, 2018

I tried to run even a tmp express server, serving a static graphql.json schema... but when providing an url, it seems that the url is directly read from the apollo api, not from the publish command...

@flippidippi
Copy link

flippidippi commented Nov 14, 2018

For now I was able to use an apollo.config.js to get it to work.

module.exports = {
  service: {
    name: "service_name",
    localSchemaFile: "./path/to/schema.json"
  }
}

@MattHartz
Copy link

@flipxfx What does your original command look like? I created a custom apollo.config.js file and put that in the cmd and still the same results.

Thanks!

@flippidippi
Copy link

It's just apollo schema:publish after writing the JSON file. I have ENGINE_API_KEY already in env.

@lirbank
Copy link

lirbank commented Nov 16, 2018

Please note that the documentation says endpoint, but it should be url. This config works (project is not using Engine):

module.exports = {
  client: {
    service: {
      url: 'http://localhost:4000/graphql',
    },
    includes: ['{client,server}/src/**/*.{ts,tsx}'],
  },
};

Using endpoint (or anything else) causes the TypeError: Only absolute URLs are supported error to appear.

@flippidippi
Copy link

That's documentation for editor plugins, not what the original question is. Here is the conflicting documentation that says --endpoint can be configured as a local file. https://www.apollographql.com/docs/engine/features/schema-history.html#schema-sources

@trevor-scheer
Copy link
Member

@flipxfx thanks for pointing out the dated docs, should be up-to-date now!
https://www.apollographql.com/docs/engine/features/schema-history.html

@aergonaut
Copy link
Author

Thanks @trevor-scheer

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

No branches or pull requests

6 participants