Skip to content

Commit

Permalink
Add forward compatible alias 'Undefined' for 'INVALID' (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Feb 2, 2020
1 parent bb72e00 commit 9c96efa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ a query language for APIs created by Facebook.
The current version 3.0.2 of GraphQL-core is up-to-date
with GraphQL.js version 14.6.0.

All parts of the API are covered by an extensive test suite
of currently 1991 unit tests.
All parts of the API are covered by an extensive test suite of nearly 2000 unit tests.


## Documentation
Expand Down
5 changes: 4 additions & 1 deletion src/graphql/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@
located_error,
format_error,
print_error,
INVALID,
INVALID, # deprecated in the next minor release
)

# Utilities for operating on GraphQL type schema and parsed sources.
Expand Down Expand Up @@ -399,6 +399,8 @@
find_dangerous_changes,
)

Undefined = INVALID # forward-compatible alias

# The GraphQL-core version info.
__version__ = version
__version_info__ = version_info
Expand Down Expand Up @@ -688,4 +690,5 @@
"BreakingChangeType",
"DangerousChange",
"DangerousChangeType",
"Undefined",
]
3 changes: 3 additions & 0 deletions src/graphql/error/invalid.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ def __ne__(self, other):
This singleton object is used to describe invalid or undefined values.
It corresponds to the ``undefined`` value in GraphQL.js.
Note: This will be considered deprecated in the next minor release.
Please use ``graphql.Undefined`` instead to create forward compatible code.
"""
5 changes: 5 additions & 0 deletions tests/error/test_invalid.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ def only_equal_to_itself():
false_object = False
assert INVALID != false_object
assert not INVALID == false_object

def forward_compatibility():
from graphql import Undefined

assert INVALID is Undefined

0 comments on commit 9c96efa

Please sign in to comment.