ExShopifySchema.Generator.Graphql.Introspection.Util.Builder (ExShopifySchema v2024.4.2)

View Source

Utility module for building GraphQL components from introspection JSON data.

Summary

Functions

Builds a list of directives from the introspection JSON data.

Builds a list of operation types from the introspection JSON data.

Builds a list of GraphQL types from the introspection JSON data.

Functions

build_directives(directives)

@spec build_directives(nil | [json_object()]) :: [
  ExShopifySchema.Generator.Graphql.Introspection.Definition.Directive.t()
]

Builds a list of directives from the introspection JSON data.

Example

iex> json = [
...>   %{"name" => "include", "description" => "Include this field if true."},
...>   %{"name" => "skip", "description" => "Skip this field if true."}
...> ]
iex> ExShopifySchema.Graphql.Introspection.Util.Builder.build_directives(json)
[
  %ExShopifySchema.Graphql.Introspection.Definition.Directive{name: "include", description: "Include this field if true."},
  %ExShopifySchema.Graphql.Introspection.Definition.Directive{name: "skip", description: "Skip this field if true."}
]

build_operations(json)

Builds a list of operation types from the introspection JSON data.

Example

iex> json = %{
...>   "query_type" => "RootQuery",
...>   "mutation_type" => "Mutation",
...>   "subscription_type" => "Subscription"
...> }
iex> ExShopifySchema.Graphql.Introspection.Util.Builder.build_operations(json)
[
  %ExShopifySchema.Graphql.Introspection.Definition.OperationType{operation: "query", type: "RootQuery"},
  %ExShopifySchema.Graphql.Introspection.Definition.OperationType{operation: "mutation", type: "Mutation"},
  %ExShopifySchema.Graphql.Introspection.Definition.OperationType{operation: "subscription", type: "Subscription"}
]

build_types(types)

@spec build_types([json_object()]) :: [
  ExShopifySchema.Generator.Graphql.Introspection.Definition.type()
]

Builds a list of GraphQL types from the introspection JSON data.

Example

iex> json = [
...>   %{"kind" => "SCALAR", "name" => "String"}
...> ]
iex> ExShopifySchema.Graphql.Introspection.Util.Builder.build_types(json)
[
  %ExShopifySchema.Graphql.Introspection.Definition.ScalarType{name: "String"}
]