View Source BridgeEx.Extensions.ExternalResources (bridge_ex v2.4.0)
Preload a set of resources marking them as "external" and provide the related getter functions.
Options
resources
(required): enumerable of resource names (atoms) and their paths (strings). Each path is assumed to be relative to the module directory.
Examples
defmodule MyBridge do
use BridgeEx.Extensions.ExternalResources,
resources: [
my_query: "queries/query.graphql",
my_mutation: "mutations/mutation.graphql"
]
# it generates the following code:
@external_resource "#{__DIR__}/queries/query.graphql"
@external_resource "#{__DIR__}/mutations/mutation.graphql"
@spec my_query() :: String.t()
def my_query, do: Map.fetch!(external_resources(), :my_query)
@spec my_mutation() :: String.t()
def my_mutation, do: Map.fetch!(external_resources(), :my_mutation)
defp external_resources do
%{
my_query: "contents of query.graphql",
my_mutation: "contents of mutation.graphql"
}
end
end