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

Support :path option to import_sdl #630

Merged
merged 4 commits into from
Nov 7, 2018
Merged

Support :path option to import_sdl #630

merged 4 commits into from
Nov 7, 2018

Conversation

bruce
Copy link
Contributor

@bruce bruce commented Nov 6, 2018

This adds support for the import_sdl/1 and import_sdl/2 notation macros to load SDL from a file location while supporting recompilation via @external_resource.

This also adds support for more flexible arguments to the macro (supporting function calls, etc)

Example

Given the following SDL:

type Query {
  hello: String!
}
defmodule MyAppWeb.Schema do
  use Absinthe.Schema

  # Option 1: Embed it
  import_sdl """
  type Query {
    hello: String!
  }
  """

  # Option 2: Load it (from a file, etc) using custom logic:
  import_sdl File.read!("path/to/schema.graphql")

  # Option 3: Load it from a file, supporting recompilation on-change:
  import_sdl path: "schema.graphql"

  # Option 4: The same as above, but programmatically determining the path:
  import_sdl path: Path.join(:code.priv_dir(:myapp), "schema.graphql")

  # Not shown: Use decorations to apply resolvers, etc
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant