Module: ArSync::ApiControllerConcern
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/ar_sync/rails.rb
Instance Method Summary collapse
- #graphql_call ⇒ Object
- #graphql_schema ⇒ Object
- #schema ⇒ Object
- #static_call ⇒ Object
- #sync_call ⇒ Object
Instance Method Details
#graphql_call ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ar_sync/rails.rb', line 59 def graphql_call render json: ArSerializer::GraphQL.serialize( schema, params[:query], operation_name: params[:operationName], variables: (params[:variables] || {}).as_json, context: current_user ) rescue StandardError => e render json: { error: handle_exception(e) } end |
#graphql_schema ⇒ Object
55 56 57 |
# File 'lib/ar_sync/rails.rb', line 55 def graphql_schema render plain: ArSerializer::GraphQL.definition(schema.class) end |
#schema ⇒ Object
45 46 47 |
# File 'lib/ar_sync/rails.rb', line 45 def schema raise 'you must implement method `schema`' end |
#static_call ⇒ Object
71 72 73 74 75 |
# File 'lib/ar_sync/rails.rb', line 71 def static_call _api_call :static do |schema, current_user, query| ArSerializer.serialize schema, query, context: current_user end end |
#sync_call ⇒ Object
49 50 51 52 53 |
# File 'lib/ar_sync/rails.rb', line 49 def sync_call _api_call :sync do |schema, current_user, query| ArSync.sync_serialize schema, current_user, query end end |