debian-mirror-gitlab/spec/requests/api/graphql/multiplexed_queries_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1.1 KiB
Ruby
Raw Normal View History

2019-09-04 21:01:54 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-05-27 22:25:52 +05:30
RSpec.describe 'Multiplexed queries', feature_category: :shared do
2019-09-04 21:01:54 +05:30
include GraphqlHelpers
it 'returns responses for multiple queries' do
queries = [
2019-12-04 20:38:33 +05:30
{ query: 'query($text: String!) { echo(text: $text) }',
2019-09-04 21:01:54 +05:30
variables: { 'text' => 'Hello' } },
2019-12-04 20:38:33 +05:30
{ query: 'query($text: String!) { echo(text: $text) }',
2019-09-04 21:01:54 +05:30
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 = [
2019-12-04 20:38:33 +05:30
{ query: 'query($text: String!) { broken query }' },
{ query: 'query working($text: String!) { echo(text: $text) }',
2019-09-04 21:01:54 +05:30
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