Hi. I’m using https://graphql-code-generator.com/ (https://www.npmjs.com/package/@graphql-codegen/cli). I am using it with the schema generated by Fauna, since it includes a lot of generated content beyond my original schema, such as scalars, _id, _ts, input types, queries, and so on. It’s a bit annoying to use the FaunaDB GraphQL schema right now, and it would be nice to be improved sometime.
(The biggest one) AFAICT I can’t automatically download the FaunaDB graphql anywhere, via a script. I haven’t dug into the dashboard code to see if there’s a better option, but the only thing I see to do is download it manually from the dashboard’s GraphQL. That’s not build-script-friendly. If I missed an option in the docs, please let me know, with my apologies.
The doc strings in my original GraphQL have been converted to comments in the Fauna GraphQL export, so that the generated typescript doesn’t have the help.
The directives in the GraphQL export confuse the parser. I remove those.
There’s an odd newline I have to correct.
# The Long scalar type represents non-fractional signed whole numeric values.
The way to get a remote schema is to use introspection queries. This is not unique to Fauna, just how you would work with any remote GraphQL server. You can point a graphQL client at the graphql endpoint and send the request in a script. graphql-request, might be a lightweight solution.
introspectSchema is a graphql-tools function that is exported from just about everything apollo.
introspection docs page:
UPDATE (6 Jan 2022):
This was an issue with GraphQL Playground and was fixed with a recent update to the Dashboard. Downloading the schema from the GraphQL playground works as expected now.
Anyone coming here in the future, I simply solved the first point (automatic download) by pointing graphql-codegen to the server simply like this: (in the codegen config file)