View Source GraphQLDocument.Name (GraphQLDocument v0.2.2)

The GraphQL specification defines a Name as starting with a letter or underscore. It may only contain letters, underscores, and digits.

The names of Fields, Types, Arguments, Variables, Directives, Fragments, and Enums must all conform to this definition.

Link to this section Summary

Types

t()

A Name can be expressed as an atom or string.

Functions

Returns a Name as a string to be inserted into a Document.

Link to this section Types

@type t() :: atom() | String.t()

A Name can be expressed as an atom or string.

Link to this section Functions

@spec render!(atom() | String.t()) :: String.t()

Returns a Name as a string to be inserted into a Document.

Raises an ArgumentError if the name doesn't start with a letter or underscore, or if it contains any characters other than letters, underscores, or digits.

examples

Examples

iex> render!("_QuiGonJinn")
"_QuiGonJinn"

iex> render!(ObiWan)
"ObiWan"

iex> render!(:DinDjarin)
"DinDjarin"

iex> render!(:leia_organa)
"leia_organa"

iex> render!("0_StartingDigit")
** (ArgumentError) 0_StartingDigit is not a valid GraphQL name

iex> render!("_Qui-Gon Jinn")
** (ArgumentError) _Qui-Gon Jinn is not a valid GraphQL name

iex> render!("*;-!")
** (ArgumentError) *;-! is not a valid GraphQL name