mix graphql_query.schema.fetch (graphql_query v0.6.1)

View Source

Fetches remote GraphQL schemas and saves them to the local filesystem.

Discovers all modules that use GraphqlQuery.Schema with a :remote configuration and downloads their schemas from the configured URLs.

Usage

# Fetch all remote schemas
mix graphql_query.schema.fetch

# Fetch a specific schema module
mix graphql_query.schema.fetch MyApp.ExternalSchema

Configuration

Schema modules must be configured with the :remote option:

defmodule MyApp.ExternalSchema do
  use GraphqlQuery.Schema,
    remote: [url: "https://api.example.com/schema.graphql"]
end

For APIs that only support introspection (no direct SDL endpoint):

defmodule MyApp.IntrospectedSchema do
  use GraphqlQuery.Schema,
    remote: [url: "https://api.example.com/graphql", mode: :introspect]
end

The schemas directory can be configured at multiple levels:

  1. Per-module :schemas_dir option in use GraphqlQuery.Schema
  2. Application config: config :graphql_query, schemas_dir: "priv/graphql/schemas"
  3. Default: "priv/graphql/schemas"