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

what is the difference between apollo and apollo-codegen? #466

Closed
jeffwillette opened this issue Jun 30, 2018 · 13 comments
Closed

what is the difference between apollo and apollo-codegen? #466

jeffwillette opened this issue Jun 30, 2018 · 13 comments

Comments

@jeffwillette
Copy link

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?

@TLadd
Copy link
Contributor

TLadd commented Jun 30, 2018

They just recently renamed this repository from apollo-codegen to apollo-cli. apollographql/rover#447 https://twitter.com/apollographql/status/1012378306195415040

@jeffwillette
Copy link
Author

ok, so going forward, we should be using the apollo command only?

@jeffwillette
Copy link
Author

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?

@mwarger
Copy link
Contributor

mwarger commented Jul 4, 2018

@deltaskelta - I've found that it's just moved, but the documentation isn't great.

apollo schema:download --endpoint ./path/to/your/schema.graphql

@trevor-scheer
Copy link
Member

2 different things I think. The docs lgtm 🤷‍♂️

Download:
apollo schema:download --endpoint

Generate:
apollo codegen:generate --schema

@jeffwillette
Copy link
Author

@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

@mwarger
Copy link
Contributor

mwarger commented Jul 5, 2018

I just happened to try it and it seemed to work fine. I made a PR for the docs. apollographql/rover#475

@ghost
Copy link

ghost commented Sep 4, 2018

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.

@lukepighetti
Copy link

lukepighetti commented Nov 9, 2018

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.

@simiyu1
Copy link

simiyu1 commented Nov 14, 2018

I found this document very well written... it also has

apollo schema:download --endpoint=http://localhost:8080/graphql schema.json

Apollo graphql guide

@lukepighetti
Copy link

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?

@cmcaboy
Copy link

cmcaboy commented Nov 25, 2018

@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
  1. 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 apollo@2.1.3. 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.

@henry74
Copy link

henry74 commented Dec 7, 2018

@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

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

9 participants