gitlab-org--gitlab-foss/spec/requests/api/graphql/multiplexed_queries_spec.rb
Brett Walker bdd5b5b695 Replace echo function with a resolver
The `GraphQL::Function` has been deprecated in
favor of resolvers.
2019-08-26 17:43:38 +00:00

39 lines
1.1 KiB
Ruby

# frozen_string_literal: true
require 'spec_helper'
describe 'Multiplexed queries' do
include GraphqlHelpers
it 'returns responses for multiple queries' do
queries = [
{ query: 'query($text: String!) { echo(text: $text) }',
variables: { 'text' => 'Hello' } },
{ query: 'query($text: String!) { echo(text: $text) }',
variables: { 'text' => 'World' } }
]
post_multiplex(queries)
first_response = json_response.first['data']['echo']
second_response = json_response.last['data']['echo']
expect(first_response).to eq('nil says: Hello')
expect(second_response).to eq('nil says: World')
end
it 'returns error and data combinations' do
queries = [
{ query: 'query($text: String!) { broken query }' },
{ query: 'query working($text: String!) { echo(text: $text) }',
variables: { 'text' => 'World' } }
]
post_multiplex(queries)
first_response = json_response.first['errors']
second_response = json_response.last['data']['echo']
expect(first_response).not_to be_empty
expect(second_response).to eq('nil says: World')
end
end