Sha256: 0b254632bbf9df0fe3ff16b2e80f59beb8d02ba6e668a6020841e943d7c05eba

Contents?: true

Size: 563 Bytes

Versions: 9

Compression:

Stored size: 563 Bytes

Contents

# frozen_string_literal: true

require "net/http"
require "uri"
require "json"

module GraphQL
  module Stitching
    class RemoteClient
      def initialize(url:, headers:{})
        @url = url
        @headers = { "Content-Type" => "application/json" }.merge!(headers)
      end

      def call(_location, document, variables, _context)
        response = Net::HTTP.post(
          URI(@url),
          JSON.generate({ "query" => document, "variables" => variables }),
          @headers,
        )
        JSON.parse(response.body)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
graphql-stitching-0.3.6 lib/graphql/stitching/remote_client.rb
graphql-stitching-0.3.4 lib/graphql/stitching/remote_client.rb
graphql-stitching-0.3.3 lib/graphql/stitching/remote_client.rb
graphql-stitching-0.3.2 lib/graphql/stitching/remote_client.rb
graphql-stitching-0.3.1 lib/graphql/stitching/remote_client.rb
graphql-stitching-0.3.0 lib/graphql/stitching/remote_client.rb
graphql-stitching-0.2.3 lib/graphql/stitching/remote_client.rb
graphql-stitching-0.2.2 lib/graphql/stitching/remote_client.rb
graphql-stitching-0.2.1 lib/graphql/stitching/remote_client.rb