Sha256: fb76f231f1be6e7d700086a2af9512523df4d506767e1a91b1bbbf1d2723c3db
Contents?: true
Size: 1.69 KB
Versions: 2
Compression:
Stored size: 1.69 KB
Contents
require 'active_support/file_update_checker' module Artemis class Railtie < ::Rails::Railtie #:nodoc: initializer 'graphql.client.attach_log_subscriber' do if !defined?(GraphQL::Client::LogSubscriber) require "graphql/client/log_subscriber" GraphQL::Client::LogSubscriber.attach_to :graphql end end initializer 'graphql.client.set_query_paths' do |app| app.paths.add "app/operations" Artemis::Client.query_paths = app.paths["app/operations"].existent end initializer 'graphql.client.set_reloader', after: 'graphql.client.set_query_paths' do |app| files_to_watch = Artemis::Client.query_paths.map {|path| [path, ["graphql"]] }.to_h app.reloaders << ActiveSupport::FileUpdateChecker.new([], files_to_watch) do endpoint_names = app.config_for(:graphql).keys endpoint_names.each do |endpoint_name| Artemis::Client.query_paths.each do |path| FileUtils.touch("#{path}/#{endpoint_name}.rb") end end end end initializer 'graphql.client.load_config' do |app| # TODO: Remove the +rescue+ call (app.config_for(:graphql) rescue {}).each do |endpoint_name, options| Artemis::GraphQLEndpoint.register!(endpoint_name, { 'schema_path' => app.root.join("vendor/graphql/schema/#{endpoint_name}.json").to_s }.merge(options)) end end initializer 'graphql.client.preload', after: 'graphql.client.load_config' do |app| if app.config.eager_load app.config_for(:graphql).keys.each do |endpoint_name| endpoint_name.to_s.camelize.constantize.preload! end end end rake_tasks do load "tasks/artemis.rake" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
artemis-0.2.0 | lib/artemis/railtie.rb |
artemis-0.1.0 | lib/artemis/railtie.rb |