Open LasseRosenow opened 4 years ago
Hi. Referring to this article https://medium.com/@v.ditsyak/ultimate-toolchain-to-work-with-graphql-in-flutter-13aef79c6484 - having the schema locally will benefit in code completion in your graphql files
Hey @lazylazyllama!
Yeah, that sure would be nice (and we can think of a way of saving it to disk and still benefit from code completion).
My only concern with this is mostly API's would required an authentication mechanism (something easy as header tokens, but most times certs that would require a custom http client).
Hey @comigor!
Cool that you've added tool/fetch_schema.dart
, now it's not necessary to fetch schema with npm packages or other non-dart ways 🙂
It would be also cool to have this util in bin
folder as described here to be able to run it through
pub run artemis:fetch_schema
or
flutter pub run artemis:fetch_schema
Thanks!
Hey @vanelizarov,
That's of course a quick way of doing it, but it doesn't solve the authentication problem I've mentioned before.
Also, we're working on adding SDL support for schemas (https://github.com/comigor/artemis/pull/82) and then we'd need to change this. But feel free to open a PR if you'd like to use this tool right now!
Hey @comigor,
Just checking in, is it possible to fetch a schema directly from an endpoint? Our API isn't gated by an authentication header for introspection.
Thanks in advance!
Do you have any plans to support this in the library so that a schema can be specified as an endpoint?
targets:
$default:
builders:
artemis:
options:
schema_mapping:
- output: lib/graphql_api.dart
schema: https://{some endpoint}/graphql
queries_glob: lib/**.graphql
@comigor Any update on this ?
Coming from React Native, codegen allowed that really easily just by setting the endpoint in the codegen.yml
file.
For the authentication problem, according to https://github.com/dotansimha/graphql-code-generator/issues/2029 here's what was needed with codegen
:
schema:
- http://localhost:3000/graphql:
headers:
Authorization: "Bearer: ${API_TOKEN}"
If you use the javascript graphql "Apollo", then you don't have do put any schema.json or schema.graphql in your project at all. Apollo automatically gets the current schema just by the url you specify like this:
schema: https://example.myapi.com/gql/graphql
I think it would be cool to have this in artemis as well.