Skip to content

Commit c469282

Browse files
Revert patch in @keys
1 parent 5bb34d7 commit c469282

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

graphene_federation/entity.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,19 @@ def key(fields: str) -> Callable:
8787
"""
8888
Take as input a field that should be used as key for that entity.
8989
See specification: https://www.apollographql.com/docs/federation/federation-spec/#key
90+
91+
If the input contains a space it means it's a [compound primary key](https://www.apollographql.com/docs/federation/entities/#defining-a-compound-primary-key)
92+
which is not yet supported.
9093
"""
94+
if " " in fields:
95+
raise NotImplementedError("Compound primary keys are not supported.")
9196

9297
def decorator(Type):
98+
# Check the provided fields actually exist on the Type.
99+
assert (
100+
fields in Type._meta.fields
101+
), f'Field "{fields}" does not exist on type "{Type._meta.name}"'
102+
93103
keys = getattr(Type, "_keys", [])
94104
keys.append(fields)
95105
setattr(Type, "_keys", keys)

0 commit comments

Comments
 (0)