Skip to content

Commit 9c96efa

Browse files
committed
Add forward compatible alias 'Undefined' for 'INVALID' (#77)
1 parent bb72e00 commit 9c96efa

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ a query language for APIs created by Facebook.
1515
The current version 3.0.2 of GraphQL-core is up-to-date
1616
with GraphQL.js version 14.6.0.
1717

18-
All parts of the API are covered by an extensive test suite
19-
of currently 1991 unit tests.
18+
All parts of the API are covered by an extensive test suite of nearly 2000 unit tests.
2019

2120

2221
## Documentation

src/graphql/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@
328328
located_error,
329329
format_error,
330330
print_error,
331-
INVALID,
331+
INVALID, # deprecated in the next minor release
332332
)
333333

334334
# Utilities for operating on GraphQL type schema and parsed sources.
@@ -399,6 +399,8 @@
399399
find_dangerous_changes,
400400
)
401401

402+
Undefined = INVALID # forward-compatible alias
403+
402404
# The GraphQL-core version info.
403405
__version__ = version
404406
__version_info__ = version_info
@@ -688,4 +690,5 @@
688690
"BreakingChangeType",
689691
"DangerousChange",
690692
"DangerousChangeType",
693+
"Undefined",
691694
]

src/graphql/error/invalid.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,7 @@ def __ne__(self, other):
3030
3131
This singleton object is used to describe invalid or undefined values.
3232
It corresponds to the ``undefined`` value in GraphQL.js.
33+
34+
Note: This will be considered deprecated in the next minor release.
35+
Please use ``graphql.Undefined`` instead to create forward compatible code.
3336
"""

tests/error/test_invalid.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ def only_equal_to_itself():
2626
false_object = False
2727
assert INVALID != false_object
2828
assert not INVALID == false_object
29+
30+
def forward_compatibility():
31+
from graphql import Undefined
32+
33+
assert INVALID is Undefined

0 commit comments

Comments
 (0)