Sha256: d4d9bbd73ae02fdcd7c345b4c4ea006422a09854553939c0e7817629c35cfe19

Contents?: true

Size: 894 Bytes

Versions: 15

Compression:

Stored size: 894 Bytes

Contents

# frozen_string_literal: true

require 'rackup'
require 'json'
require 'graphql'
require_relative '../../lib/graphql/stitching'
require_relative './helpers'

class StitchedApp
  def initialize
    @client = GraphQL::Stitching::Client.new(locations: {
      gateway: {
        schema: GatewaySchema,
      },
      remote: {
        schema: RemoteSchema,
        executable: GraphQL::Stitching::HttpExecutable.new(
          url: "http://localhost:3001",
          upload_types: ["Upload"]
        ),
      },
    })
  end

  def call(env)
    params = apollo_upload_server_middleware_params(env)
    result = @client.execute(
      query: params["query"],
      variables: params["variables"],
      operation_name: params["operationName"],
    )

    [200, {"content-type" => "application/json"}, [JSON.generate(result)]]
  end
end

Rackup::Handler.default.run(StitchedApp.new, :Port => 3000)

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
graphql-stitching-1.6.0 examples/file_uploads/gateway.rb
graphql-stitching-1.5.2 examples/file_uploads/gateway.rb
graphql-stitching-1.5.1 examples/file_uploads/gateway.rb
graphql-stitching-1.5.0 examples/file_uploads/gateway.rb
graphql-stitching-1.4.3 examples/file_uploads/gateway.rb
graphql-stitching-1.4.2 examples/file_uploads/gateway.rb
graphql-stitching-1.4.1 examples/file_uploads/gateway.rb
graphql-stitching-1.4.0 examples/file_uploads/gateway.rb
graphql-stitching-1.3.0 examples/file_uploads/gateway.rb
graphql-stitching-1.2.5 examples/file_uploads/gateway.rb
graphql-stitching-1.2.4 examples/file_uploads/gateway.rb
graphql-stitching-1.2.3 examples/file_uploads/gateway.rb
graphql-stitching-1.2.2 examples/file_uploads/gateway.rb
graphql-stitching-1.2.1 examples/file_uploads/gateway.rb
graphql-stitching-1.2.0 examples/file_uploads/gateway.rb