TypedStructor.Plugins.Access (Grephql v0.10.1)

Copy Markdown View Source

A TypedStructor plugin that implements the Access behaviour for structs.

This allows bracket-based field access on generated schemas:

schema[:field_name]
get_in(schema, [:nested, :field])

Deleting keys via pop/2 is not supported — structs have a fixed set of fields — so pop/2 raises an error.

Usage

Register the plugin inside a typed_structor or typed_embedded_schema block:

typed_embedded_schema do
  plugin TypedStructor.Plugins.Access

  field :name, :string
end

Or register it globally in config:

config :typed_structor, plugins: [TypedStructor.Plugins.Access]