Absinthe supports an adapter mechanism that allows developers to define their
schema using one code convention (eg,
snake_cased fields and arguments), but
accept query documents and return results (including names in errors) in
camelCase). This is useful in allowing both client and server to
use conventions most natural to them.
Absinthe ships with two adapters:
Absinthe.Adapter.LanguageConventions, which expects schemas to be defined in
snake_case(the standard Elixir convention), translating to/from
camelCasefor incoming query documents and outgoing results. (This is the default as of v0.3.)
Absinthe.Adapter.Passthrough, which is a no-op adapter and makes no modifications.
To set the adapter, you can set an application configuration value:
Or, you can provide it as an option to
Notably, this means you’re able to switch adapters on case-by-case basis. In a Phoenix application, this means you could even support using different adapters for different clients.
A custom adapter module must merely implement the
in many cases with
use Absinthe.Adapter and only overriding the desired
Note that types that are defined external to your application (including the introspection types) may not be compatible if you’re using a different adapter.