Absinthe.Adapter.LanguageConventions (absinthe v1.5.4) View Source

This defines an adapter that supports GraphQL query documents in their conventional (in JS) camelcase notation, while allowing the schema to be defined using conventional (in Elixir) underscore (snakecase) notation, and tranforming the names as needed for lookups, results, and error messages.

For example, this document:

{
  myUser: createUser(userId: 2) {
    firstName
    lastName
  }
}

Would map to an internal schema that used the following names:

  • create_user instead of createUser
  • user_id instead of userId
  • first_name instead of firstName
  • last_name instead of lastName

Likewise, the result of executing this (camelcase) query document against our (snakecase) schema would have its names transformed back into camelcase on the way out:

%{
  data: %{
    "myUser" => %{
      "firstName" => "Joe",
      "lastName" => "Black"
    }
  }
}

Note variables are a client-facing concern (they may be provided as parameters), so variable names should match the convention of the query document (eg, camelCase).

Link to this section Summary

Functions

Converts a snake_case name to camelCase

Converts a camelCase to snake_case

Link to this section Functions

Link to this function

to_external_name(internal_name, role)

View Source

Converts a snake_case name to camelCase

Link to this function

to_internal_name(external_name, role)

View Source

Converts a camelCase to snake_case