Search code examples
windowsgradlegraphqlapolloapollo-client

Apollo on android: can't download schema or generate classes


I'm trying Apollo and graphql for the first time and I want to use this api and I'm following the official example here. However

running the schema download task

gradlew :app:downloadApolloSchema --endpoint='https://countries.trevorblades.com/' --schema='app/src/main/graphql/com/trevorblades/countries/schema.json'

results in

 Execution failed for task ':app:downloadApolloSchema'.
> Expected URL scheme 'http' or 'https' but no colon was found

with both the repo I want to use and the example's.

If I try to manually download the schema using the button on the repo's page, place it in the correct directory and run

gradlew generateApolloSources

it results in

 Failed to parse GraphQL schema introspection query from `[...]app\src\main\graphql\com\trevorblades\countries\schema.json`

again with both my repo and the one from the example.

I've the feeling that I'm missing something really trivial here, but I really can't figure it out.

any help will be appreciated.


Solution

  • Try the JS GraphQL IDEA plugin, which might make life a tad easier. And as it suggested here ...you might not pass a valid endpoint at all. Try --endpoint=https://countries.trevorblades.com/ or in " double-quotes . The error message is definitely concerning the --endpoint and not concerning the --schema. I have the suspicion that Windows might not like these ' single quotes (obviously the same would also apply to --schema).

    gradlew.bat :app:downloadApolloSchema --endpoint=https://countries.trevorblades.com/ --schema=app/src/main/graphql/com/trevorblades/countries/schema.json
    

    or:

    gradlew.bat :app:downloadApolloSchema --endpoint="https://countries.trevorblades.com/" --schema="app/src/main/graphql/com/trevorblades/countries/schema.json"