mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-09-20 15:09:02 +03:00
server: fix handling of empty array values in relationships of set_custom_types API (#219)
* server: fix handling of empty array values in relationships of set_custom_types * add a test for dropping the relationship GitOrigin-RevId: abff138b0021647a1cb6c6c041c2ba53c1ff9b77
This commit is contained in:
parent
a18cd6b1bc
commit
ef33a61266
@ -86,6 +86,7 @@ and be accessible according to the permissions that were configured for the role
|
|||||||
- server: do not block catalog migration on inconsistent metadata
|
- server: do not block catalog migration on inconsistent metadata
|
||||||
- server: update `forkImmortal` function to log more information, i.e log starting of threads and log asynchronous and synchronous exception.
|
- server: update `forkImmortal` function to log more information, i.e log starting of threads and log asynchronous and synchronous exception.
|
||||||
- server: various changes to ensure timely cleanup of background threads and other resources in the event of a SIGTERM signal.
|
- server: various changes to ensure timely cleanup of background threads and other resources in the event of a SIGTERM signal.
|
||||||
|
- server: fix issue when the `relationships` field in `objects` field is passed `[]` in the `set_custom_types` API (fix #6357)
|
||||||
- console: allow user to cascade Postgres dependencies when dropping Postgres objects (close #5109) (#5248)
|
- console: allow user to cascade Postgres dependencies when dropping Postgres objects (close #5109) (#5248)
|
||||||
- console: mark inconsistent remote schemas in the UI (close #5093) (#5181)
|
- console: mark inconsistent remote schemas in the UI (close #5093) (#5181)
|
||||||
- console: remove ONLY as default for ALTER TABLE in column alter operations (close #5512) #5706
|
- console: remove ONLY as default for ALTER TABLE in column alter operations (close #5512) #5706
|
||||||
|
@ -150,7 +150,21 @@ data ObjectTypeDefinition a b c
|
|||||||
} deriving (Show, Eq, Generic)
|
} deriving (Show, Eq, Generic)
|
||||||
instance (NFData a, NFData b, NFData c) => NFData (ObjectTypeDefinition a b c)
|
instance (NFData a, NFData b, NFData c) => NFData (ObjectTypeDefinition a b c)
|
||||||
instance (Cacheable a, Cacheable b, Cacheable c) => Cacheable (ObjectTypeDefinition a b c)
|
instance (Cacheable a, Cacheable b, Cacheable c) => Cacheable (ObjectTypeDefinition a b c)
|
||||||
$(J.deriveJSON (J.aesonDrop 4 J.snakeCase) ''ObjectTypeDefinition)
|
$(J.deriveToJSON (J.aesonDrop 4 J.snakeCase) ''ObjectTypeDefinition)
|
||||||
|
|
||||||
|
instance (J.FromJSON a, J.FromJSON b, J.FromJSON c) => J.FromJSON (ObjectTypeDefinition a b c) where
|
||||||
|
parseJSON = J.withObject "ObjectTypeDefinition" \obj -> do
|
||||||
|
name <- obj J..: "name"
|
||||||
|
desc <- obj J..:? "description"
|
||||||
|
fields <- obj J..: "fields"
|
||||||
|
relationships <- obj J..:? "relationships"
|
||||||
|
-- We need to do the below because pre-PDV, '[]' was a legal value
|
||||||
|
-- for relationships because the type was `(Maybe [TypeRelationshipDefinition])`,
|
||||||
|
-- In PDV, the type was changed to `(Maybe (NonEmpty (TypeRelationship b c)))`
|
||||||
|
-- which breaks on `[]` for the `relationships` field, to be backwards compatible
|
||||||
|
-- this `FromJSON` instance is written by hand and `[]` sets `_otdRelationships`
|
||||||
|
-- to `Nothing`
|
||||||
|
return $ ObjectTypeDefinition name desc fields (nonEmpty =<< relationships)
|
||||||
|
|
||||||
data ScalarTypeDefinition
|
data ScalarTypeDefinition
|
||||||
= ScalarTypeDefinition
|
= ScalarTypeDefinition
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
- description: Set custom types with an object relationship
|
||||||
|
url: /v1/query
|
||||||
|
status: 200
|
||||||
|
query:
|
||||||
|
type: set_custom_types
|
||||||
|
args:
|
||||||
|
objects:
|
||||||
|
- name: User
|
||||||
|
fields:
|
||||||
|
- name: user_id
|
||||||
|
type: uuid!
|
||||||
|
- name: name
|
||||||
|
type: 'String!'
|
||||||
|
relationships:
|
||||||
|
- name: Names
|
||||||
|
type: array
|
||||||
|
remote_table: user
|
||||||
|
field_mapping:
|
||||||
|
name: name
|
||||||
|
|
||||||
|
- description: drop the custom type relationship
|
||||||
|
url: /v1/query
|
||||||
|
status: 200
|
||||||
|
query:
|
||||||
|
type: set_custom_types
|
||||||
|
args:
|
||||||
|
objects:
|
||||||
|
- name: User
|
||||||
|
fields:
|
||||||
|
- name: user_id
|
||||||
|
type: uuid!
|
||||||
|
- name: name
|
||||||
|
type: 'String!'
|
||||||
|
relationships: []
|
@ -445,6 +445,9 @@ class TestSetCustomTypes:
|
|||||||
def test_list_type_relationship(self, hge_ctx):
|
def test_list_type_relationship(self, hge_ctx):
|
||||||
check_query_f(hge_ctx, self.dir() + '/list_type_relationship.yaml')
|
check_query_f(hge_ctx, self.dir() + '/list_type_relationship.yaml')
|
||||||
|
|
||||||
|
def test_drop_relationship(self, hge_ctx):
|
||||||
|
check_query_f(hge_ctx, self.dir() + '/drop_relationship.yaml')
|
||||||
|
|
||||||
@pytest.mark.usefixtures('per_class_tests_db_state')
|
@pytest.mark.usefixtures('per_class_tests_db_state')
|
||||||
class TestActionsMetadata:
|
class TestActionsMetadata:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user