Sha256: 50b710a224b601e7e0637ddfe09ece5d44790c1e977278c4717b0b04f57c0d26
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true module GraphqlRails class Router # builds GraphQL::Schema based on previously defined grahiti data class SchemaBuilder attr_reader :queries, :mutations, :raw_actions def initialize(queries:, mutations:, raw_actions:) @queries = queries @mutations = mutations @raw_actions = raw_actions end def call query_type = build_type('Query', queries) mutation_type = build_type('Mutation', mutations) raw = raw_actions GraphQL::Schema.define do raw.each { |action| send(action[:name], *action[:args], &action[:block]) } query(query_type) mutation(mutation_type) end end private def build_type(type_name, routes) GraphQL::ObjectType.define do name type_name routes.each do |route| field route.name, function: Controller::ControllerFunction.from_route(route) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
graphql_rails-0.2.1 | lib/graphql_rails/router/schema_builder.rb |