Module: GraphQL::Schema::Member::AcceptsDefinition Private

Included in:
GraphQL::Schema, Argument, Enum, EnumValue, Field, InputObject, Interface, Object, Scalar, Union
Defined in:
lib/graphql/schema/member/accepts_definition.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Support for legacy accepts_definitions functions.

Keep the legacy handler hooked up. Class-based types and fields will call those legacy handlers during their .to_graphql methods.

This can help out while transitioning from one to the other. Eventually, GraphQL::{X}Type objects will be removed entirely, But this can help during the transition.

Examples:

Applying a function to base object class

# Here's the legacy-style config, which we're calling back to:
GraphQL::ObjectType.accepts_definition({
  permission_level: ->(defn, value) { defn.[:permission_level] = value }
})

class BaseObject < GraphQL::Schema::Object
  # Setup a named pass-through to the legacy config functions
  accepts_definition :permission_level
end

class Account < BaseObject
  # This value will be passed to the legacy handler:
  permission_level 1
end

# The class gets a reader method which returns the args,
# only marginally useful.
Account.permission_level # => [1]

# The legacy handler is called, as before:
Account.graphql_definition.[:permission_level] # => 1

Defined Under Namespace

Modules: AcceptsDefinitionDefinitionMethods, InitializeExtension, ToGraphQLExtension