Sha256: 82c0633e9f679a6f930debc2bf8d6550f7ae9432fe980275a22d29e411d30851

Contents?: true

Size: 565 Bytes

Versions: 9

Compression:

Stored size: 565 Bytes

Contents

# frozen_string_literal: true

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

module GraphQL
  module Stitching
    class HttpExecutable
      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-1.1.1 lib/graphql/stitching/http_executable.rb
graphql-stitching-1.1.0 lib/graphql/stitching/http_executable.rb
graphql-stitching-1.0.6 lib/graphql/stitching/http_executable.rb
graphql-stitching-1.0.5 lib/graphql/stitching/http_executable.rb
graphql-stitching-1.0.4 lib/graphql/stitching/http_executable.rb
graphql-stitching-1.0.3 lib/graphql/stitching/http_executable.rb
graphql-stitching-1.0.2 lib/graphql/stitching/http_executable.rb
graphql-stitching-1.0.1 lib/graphql/stitching/http_executable.rb
graphql-stitching-1.0.0 lib/graphql/stitching/http_executable.rb