这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions server/src-lib/Hasura/GraphQL/Transport/HTTP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@ runGQBatched reqId userInfo reqHdrs reqs =
-- It's unclear what we should do if we receive multiple
-- responses with distinct headers, so just do the simplest thing
-- in this case, and don't forward any.
let removeHeaders = flip HttpResponse Nothing . encJFromList . map _hrBody
removeHeaders <$> traverse (runGQ reqId userInfo reqHdrs) batch
let removeHeaders =
flip HttpResponse Nothing
. encJFromList
. map (either (encJFromJValue . encodeGQErr False) _hrBody)
try = flip catchError (pure . Left) . fmap Right
fmap removeHeaders $
traverse (try . runGQ reqId userInfo reqHdrs) batch

runHasuraGQ
:: ( MonadIO m
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
description: GraphQL query to test batching with mixed queries and mutations
url: /v1/graphql
status: 200
response:
- data:
update_user:
affected_rows: 1
returning:
- id: '2'
- data:
user:
- id: '1'
name: User 1
- id: '2'
name: Temp User
- data:
update_user:
affected_rows: 1
returning:
- id: '2'
query:
- query: |
mutation {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is poor form (updating the test data set from a test like this), so I try to put back the original data at the end so that it doesn't affect any other tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the test setup/teardown actions run around each individual test, not around the whole test group, so I think this is unnecessary.

update_user(where: {number: {_eq: "123456780"}}, _set: {name: "Temp User"}) {
affected_rows
returning { id }
}
}
- query: |
query {
user {
id
name
}
}
- query: |
mutation {
update_user(where: {number: {_eq: "123456780"}}, _set: {name: "User 2"}) {
affected_rows
returning { id }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
description: GraphQL query to test error reporting when batching requests
url: /v1/graphql
status: 200
response:
- errors:
- extensions:
path: $.selectionSet.does_not_exist
code: validation-failed
message: "field \"does_not_exist\" not found in type: 'query_root'"
- data:
author:
- id: 1
- id: 2
query:
- query: |
query {
does_not_exist {
id
}
}
- query: |
query {
author {
id
}
}
8 changes: 8 additions & 0 deletions server/tests-py/test_graphql_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ def test_select_query_batching(self, hge_ctx, transport):
transport = 'http'
check_query_f(hge_ctx, self.dir() + "/select_query_batching.yaml", transport)

def test_select_query_batching_with_mutation(self, hge_ctx, transport):
transport = 'http'
check_query_f(hge_ctx, self.dir() + "/select_query_batching_with_mutation.yaml", transport)

def test_select_query_batching_with_one_error(self, hge_ctx, transport):
transport = 'http'
check_query_f(hge_ctx, self.dir() + "/select_query_batching_with_one_error.yaml", transport)

@classmethod
def dir(cls):
return 'queries/graphql_query/basic'
Expand Down