Открыть боковую панель
nt_test121
nt_project_9da4a5yt9x4b
Коммиты
7c369bb6
Коммит
7c369bb6
создал
Сен 11, 2019
по автору
Alessio Caiazza
Просмотр файлов
Test a real GraphQL multipart request
владелец
dee0d33f
Изменения
1
Скрыть пробелы
Построчно
Рядом
spec/support/helpers/graphql_helpers.rb
Просмотр файла @
7c369bb6
...
...
@@ -172,6 +172,31 @@ def post_graphql_mutation(mutation, current_user: nil)
post_graphql
(
mutation
.
query
,
current_user:
current_user
,
variables:
mutation
.
variables
)
end
# this implements GraphQL multipart request v2
# https://github.com/jaydenseric/graphql-multipart-request-spec/tree/v2.0.0-alpha.2
# this is simplified and do not support file deduplication
def
mutation_to_apollo_uploads_param
(
mutation
,
files:
[])
operations
=
{
'query'
=>
mutation
.
query
,
'variables'
=>
mutation
.
variables
}
map
=
{}
extracted_files
=
{}
files
.
each_with_index
do
|
file_path
,
idx
|
apollo_idx
=
(
idx
+
1
).
to_s
parent_dig_path
=
file_path
[
0
..-
2
]
file_key
=
file_path
[
-
1
]
parent
=
operations
[
'variables'
]
parent
=
parent
.
dig
(
*
parent_dig_path
)
unless
parent_dig_path
.
empty?
extracted_files
[
apollo_idx
]
=
parent
[
file_key
]
parent
[
file_key
]
=
nil
map
[
apollo_idx
]
=
[
"variables.
#{
file_path
.
join
(
'.'
)
}
"
]
end
{
operations:
operations
.
to_json
,
map:
map
.
to_json
}.
merge
(
extracted_files
)
end
# Raises an error if no data is found
def
graphql_data
json_response
[
'data'
]
||
(
raise
NoData
,
graphql_errors
)
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать