Module: ActiveAdmin::GraphQL
- Defined in:
- lib/active_admin/graphql.rb,
lib/active_admin/graphql.rb,
lib/active_admin/graphql/engine.rb,
lib/active_admin/graphql/railtie.rb,
lib/active_admin/graphql/version.rb,
lib/active_admin/graphql/integration.rb,
lib/active_admin/graphql/auth_context.rb,
lib/active_admin/graphql/schema_field.rb,
lib/active_admin/graphql/record_source.rb,
lib/active_admin/graphql/schema_builder.rb,
lib/active_admin/graphql/schema_builder.rb,
lib/active_admin/graphql/resource_config.rb,
lib/active_admin/graphql/policy_set_cache.rb,
lib/active_admin/graphql/resource_interface.rb,
lib/active_admin/graphql/run_action_payload.rb,
lib/active_admin/graphql/schema_builder/wire.rb,
lib/active_admin/graphql/key_value_pair_input.rb,
lib/active_admin/graphql/resource_query_proxy.rb,
lib/active_admin/graphql/schema_builder/build.rb,
lib/active_admin/graphql/resource_definition_dsl.rb,
lib/active_admin/graphql/run_action_mutation_dsl.rb,
lib/active_admin/graphql/schema_builder/resolvers.rb,
lib/active_admin/graphql/schema_builder/resources.rb,
lib/active_admin/graphql/schema_builder/query_type.rb,
lib/active_admin/graphql/schema_builder/visibility.rb,
lib/active_admin/graphql/run_action_mutation_config.rb,
lib/active_admin/graphql/schema_builder/graph_params.rb,
lib/active_admin/graphql/schema_builder/types_inputs.rb,
lib/active_admin/graphql/schema_builder/types_object.rb,
lib/active_admin/graphql/schema_builder/mutation_batch.rb,
lib/active_admin/graphql/schema_builder/mutation_create.rb,
lib/active_admin/graphql/schema_builder/mutation_member.rb,
lib/active_admin/graphql/resource_query_proxy/controller.rb,
lib/active_admin/graphql/schema_builder/query_type_pages.rb,
lib/active_admin/graphql/schema_builder/query_type_member.rb,
lib/active_admin/graphql/schema_builder/mutation_collection.rb,
lib/active_admin/graphql/schema_builder/query_type_policies.rb,
lib/active_admin/graphql/schema_builder/mutation_action_types.rb,
lib/active_admin/graphql/schema_builder/mutation_type_builder.rb,
lib/active_admin/graphql/schema_builder/query_type_collection.rb,
lib/active_admin/graphql/schema_builder/query_type_registered.rb,
lib/active_admin/graphql/schema_builder/mutation_update_destroy.rb,
sig/active_admin/graphql.rbs
Overview
GraphQL HTTP API for ActiveAdmin (graphql-ruby), shipped in the activeadmin-graphql gem.
Bundling activeadmin-graphql loads graphql-ruby and registers this integration. Enable the
HTTP endpoint per namespace in config/initializers/active_admin.rb:
ActiveAdmin.setup do |config|
config.namespace :admin do |api|
api.graphql = true
end
end
Defined Under Namespace
Modules: Integration, KeyValuePairs, ResourceInterface Classes: AuthContext, Engine, KeyValuePairInput, PolicySetCache, Railtie, RecordSource, ResourceConfig, ResourceDefinitionDSL, ResourceQueryProxy, RunActionMutationConfig, RunActionMutationDSL, RunActionPayload, SchemaBuilder, SchemaField
Constant Summary collapse
- SCHEMA_CACHE =
{}
- SCHEMA_CACHE_MUTEX =
Mutex.new
- VERSION =
"0.2.1"
Class Method Summary collapse
- .clear_schema_cache! ⇒ Object
- .clear_schema_for!(namespace) ⇒ Object
-
.load! ⇒ void
Requires graphql-ruby and schema builders.
- .require_active_admin_graphql_components! ⇒ Object
- .require_graphql_dependencies! ⇒ Object
-
.schema_for(namespace) ⇒ Class
Cached per namespace for the process.
Class Method Details
.clear_schema_cache! ⇒ Object
53 54 55 |
# File 'lib/active_admin/graphql.rb', line 53 def clear_schema_cache! SCHEMA_CACHE.clear end |
.clear_schema_for!(namespace) ⇒ Object
57 58 59 |
# File 'lib/active_admin/graphql.rb', line 57 def clear_schema_for!(namespace) SCHEMA_CACHE.delete(namespace.name) end |
.load! ⇒ void
This method returns an undefined value.
Requires graphql-ruby and schema builders. Safe to call repeatedly; loads once.
27 28 29 30 31 32 33 34 |
# File 'lib/active_admin/graphql.rb', line 27 def load! return if @graphql_features_loaded @graphql_features_loaded = true ActiveAdmin::Dependency["graphql"].spec! require_graphql_dependencies! require_active_admin_graphql_components! end |
.require_active_admin_graphql_components! ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/active_admin/graphql.rb', line 68 def require_active_admin_graphql_components! %w[ graphql/resource_interface graphql/schema_field graphql/auth_context graphql/record_source graphql/resource_query_proxy graphql/run_action_payload graphql/run_action_mutation_config graphql/run_action_mutation_dsl graphql/key_value_pair_input graphql/policy_set_cache graphql/schema_builder ].each { |path| require_relative path } end |
.require_graphql_dependencies! ⇒ Object
61 62 63 64 65 66 |
# File 'lib/active_admin/graphql.rb', line 61 def require_graphql_dependencies! require "graphql" require "graphql/types/json" require "graphql/types/iso_8601_date_time" require "graphql/types/iso_8601_date" end |
.schema_for(namespace) ⇒ Class
Cached per namespace for the process. In development, call
clear_schema_cache! or clear_schema_for! after ActiveAdmin unload!
(already wired in ActiveAdmin::GraphQL::Integration::ApplicationUnloadClearsGraphQLSchema) or
when admin registrations change without a full unload.
43 44 45 46 47 48 49 50 51 |
# File 'lib/active_admin/graphql.rb', line 43 def schema_for(namespace) cache_key = namespace.name cached = SCHEMA_CACHE[cache_key] return cached if cached SCHEMA_CACHE_MUTEX.synchronize do SCHEMA_CACHE[cache_key] ||= SchemaBuilder.new(namespace).build end end |