mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
server: fix condition to classify requests to Apollo persisted queries
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10514 GitOrigin-RevId: c7ada21af3984761e8521f0fc8092e27367cdc02
This commit is contained in:
parent
51bab1d6ba
commit
94f01cfbb0
@ -328,8 +328,8 @@ instance ToJSON ExtQueryReqs where
|
|||||||
instance FromJSON ExtQueryReqs where
|
instance FromJSON ExtQueryReqs where
|
||||||
parseJSON arr@Array {} = EqrGQLReq <$> (GH.GQLBatchedReqs <$> parseJSON arr)
|
parseJSON arr@Array {} = EqrGQLReq <$> (GH.GQLBatchedReqs <$> parseJSON arr)
|
||||||
parseJSON json
|
parseJSON json
|
||||||
-- The APQ requests, have a special key called as Extensions
|
-- The APQ requests, have a special object in the key `Extentions` called as `persistedQuery`
|
||||||
| isJust (json Lens.^? key "extensions") = EqrAPQReq <$> parseJSON json
|
| isJust (json Lens.^? key "extensions" . key "persistedQuery") = EqrAPQReq <$> parseJSON json
|
||||||
| otherwise = EqrGQLReq <$> (GH.GQLSingleRequest <$> parseJSON json)
|
| otherwise = EqrGQLReq <$> (GH.GQLSingleRequest <$> parseJSON json)
|
||||||
|
|
||||||
class (Monad m) => MonadGetPolicies m where
|
class (Monad m) => MonadGetPolicies m where
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
- description: Simple GraphQL object query on author, where the request includes extensions (normal request).
|
||||||
|
url: /v1/graphql
|
||||||
|
headers:
|
||||||
|
X-Hasura-Role: admin
|
||||||
|
status: 200
|
||||||
|
response:
|
||||||
|
data:
|
||||||
|
author:
|
||||||
|
- id: 1
|
||||||
|
name: Author 1
|
||||||
|
- id: 2
|
||||||
|
name: Author 2
|
||||||
|
query:
|
||||||
|
# https://graphql.org/learn/serving-over-http/#post-request
|
||||||
|
operationName: chooseThisOne
|
||||||
|
extensions: null
|
||||||
|
query: |
|
||||||
|
query chooseThisOne {
|
||||||
|
author {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- description: Simple GraphQL object query on author, where the request includes persisted query extension.
|
||||||
|
url: /v1/graphql
|
||||||
|
headers:
|
||||||
|
X-Hasura-Role: admin
|
||||||
|
status: 200
|
||||||
|
response:
|
||||||
|
errors:
|
||||||
|
- extensions:
|
||||||
|
path: $
|
||||||
|
code: not-supported
|
||||||
|
message: Automatic Persisted Queries is not enabled
|
||||||
|
query:
|
||||||
|
# https://graphql.org/learn/serving-over-http/#post-request
|
||||||
|
operationName: chooseThisOne
|
||||||
|
extensions:
|
||||||
|
persistedQuery:
|
||||||
|
version: 1
|
||||||
|
sha256Hash: randomhash
|
||||||
|
query: |
|
||||||
|
query chooseThisOne {
|
||||||
|
author {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
@ -180,6 +180,10 @@ class TestGraphQLQueryBasicPostgres:
|
|||||||
def test_create_invalid_fkey_relationship(self, hge_ctx, transport):
|
def test_create_invalid_fkey_relationship(self, hge_ctx, transport):
|
||||||
resp = hge_ctx.v1q_f(self.dir() + '/setup_invalid_fkey_relationship.yaml', expected_status_code = 400)
|
resp = hge_ctx.v1q_f(self.dir() + '/setup_invalid_fkey_relationship.yaml', expected_status_code = 400)
|
||||||
assert resp['error'] == "Expecting object { table, columns }."
|
assert resp['error'] == "Expecting object { table, columns }."
|
||||||
|
|
||||||
|
def test_select_query_with_extensions(self, hge_ctx, transport):
|
||||||
|
transport = 'http'
|
||||||
|
check_query_f(hge_ctx, self.dir() + "/select_query_with_extensions.yaml", transport)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def dir(cls):
|
def dir(cls):
|
||||||
|
Loading…
Reference in New Issue
Block a user