Sha256: 5d53826e42d36f1f5f63acdafc83574cef4f9f8c0166fea80e76867716f7582c

Contents?: true

Size: 888 Bytes

Versions: 6

Compression:

Stored size: 888 Bytes

Contents

module GraphitiGql
  class Schema
    module Fields
      class Index
        def initialize(registered)
          @registered = registered
        end

        def apply(query)
          resource = @registered[:resource]
          field = query.field resource.graphql_entrypoint,
            @registered[:type].connection_type,
            null: false,
            connection: false,
            extras: [:lookahead]
          field.extension(RelayConnectionExtension, resource: resource)
          ListArguments.new(resource).apply(field)
          query.define_method name do |**arguments|
            params = Util.params_from_args(arguments)
            proxy = resource.all(params)
            ResponseShim.new(proxy.data, proxy)
          end
        end

        private

        def name
          @registered[:resource].graphql_entrypoint
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
graphiti_gql-0.2.38 lib/graphiti_gql/schema/fields/index.rb
graphiti_gql-0.2.37 lib/graphiti_gql/schema/fields/index.rb
graphiti_gql-0.2.36 lib/graphiti_gql/schema/fields/index.rb
graphiti_gql-0.2.35 lib/graphiti_gql/schema/fields/index.rb
graphiti_gql-0.2.34 lib/graphiti_gql/schema/fields/index.rb
graphiti_gql-0.2.33 lib/graphiti_gql/schema/fields/index.rb