The readme only references the apollo command, but a lot of the issues refer to apollo-codegen, I can't find any references to the apollo-codegen command. Was that an older version?
They just recently renamed this repository from apollo-codegen to apollo-cli. https://github.com/apollographql/apollo-cli/pull/447 https://twitter.com/apollographql/status/1012378306195415040
ok, so going forward, we should be using the apollo command only?
It seems that the ability to read the schema from a graphql file is also missing from the apollo command but it is present in the apollo-codegen command.
Was this taken out?
@deltaskelta - I've found that it's just moved, but the documentation isn't great.
apollo schema:download --endpoint ./path/to/your/schema.graphql
2 different things I think. The docs lgtm 🤷♂️
Download:
apollo schema:download --endpoint
Generate:
apollo codegen:generate --schema
@trevor-scheer
the schema:download help says...
--endpoint=endpoint [default: http://localhost:4000/graphql] The URL of the server to fetch the schema from
and the codegen:generate help says
--schema=schema Path to your GraphQL schema introspection result
So there is no mention of --endpoint being able to handle graphql files instead of direct server introspection
I just happened to try it and it seemed to work fine. I made a PR for the docs. https://github.com/apollographql/apollo-cli/pull/475
Schema.json generated by apollo schema:download is slightly different from one generated apollo-code-ge introspect-schema commands. Android studio fails to compile if use first schema.json.
Have there been breaking changes to apollo cli recently? None of these commands work for me.
$ apollo schema:download --endpoint http://localhost:4000
› Warning: schema:download is not a apollo command.
I found this document very well written... it also has
apollo schema:download --endpoint=http://localhost:8080/graphql schema.json
Never would have thought to look in the iOS docs for stuff about apollo-server, thanks for the link! Any idea how to download Typescript typings?
@lukepighetti For the client, this is what I have been doing:
1) start my gql server locally
2) I'll run the following command to store my schema in a file called schema.json.
apollo service:download --endpoint=http://localhost:4000/graphql
3) I'll then run this command to generate my typescript types
apollo client:codegen --target=typescript --localSchemaFile="./schema.json" --queries="./src/apollo/**/*.ts"
````
This will look for any gql tags throughout the files that the query parameter resolves to. It will then use those operations, along with the schema file, to generate the types.
I am on [email protected]. For some reason, 2.1.2 did not work for me. I also hooked up these command into npm/yarn scripts so I don't have to manually run then every time. In order to get that to work, I had to upgrade graphql to 14.0.0 and create a resolution entry for it in package.json.
"resolutions": {
"graphql": "14.0.0"
},
```
I think there may be a way to do #2 and #3 in 1 command as apollo client:codegen has an --endpoint parameter, however, I was not able to get it to work.
@cmcaboy minor note on the --queries flag but appreciate your comment - helps clear up confusion for me!
--queries=queries Deprecated in favor of the includes flag
Most helpful comment
@trevor-scheer
the
schema:downloadhelp says...and the
codegen:generatehelp saysSo there is no mention of
--endpointbeing able to handle graphql files instead of direct server introspection