-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(graphql): ensure type names do not leak graphene (#8345)
- Loading branch information
1 parent
de10b7f
commit c32caa0
Showing
8 changed files
with
42 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
js_modules/dagit/packages/core/src/app/types/PermissionFragment.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
js_modules/dagit/packages/core/src/app/types/PermissionsQuery.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
python_modules/dagster-graphql/dagster_graphql_tests/graphql/johann
This file was deleted.
Oops, something went wrong.
44 changes: 35 additions & 9 deletions
44
python_modules/dagster-graphql/dagster_graphql_tests/test_schema.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,37 @@ | ||
from dagster_graphql.schema import types | ||
import json | ||
|
||
import pytest | ||
from click.testing import CliRunner | ||
from dagster_graphql.cli import ui | ||
|
||
def test_schema_naming_invariant(): | ||
violations = [] | ||
for type_ in types(): | ||
if type_.__name__ != f"Graphene{type_._meta.name}": # pylint: disable=protected-access | ||
violations.append( | ||
(type_.__name__, f"Graphene{type_._meta.name}") # pylint: disable=protected-access | ||
) | ||
assert not violations, violations | ||
|
||
@pytest.fixture(name="runner") | ||
def runner_fixture(): | ||
yield CliRunner() | ||
|
||
|
||
def test_schema_type_names_without_graphene(runner): | ||
query = """ | ||
query GetSchemaTypeNames { | ||
__schema { | ||
types { | ||
name | ||
} | ||
} | ||
} | ||
""" | ||
|
||
result = runner.invoke( | ||
ui, | ||
["--empty-workspace", "--ephemeral-instance", "-t", query], | ||
) | ||
graphql_schema_types = json.loads(result.output)["data"]["__schema"]["types"] | ||
|
||
violations = [ | ||
graphql_type["name"] | ||
for graphql_type in graphql_schema_types | ||
if "Graphene".casefold() in graphql_type["name"].casefold() | ||
] | ||
assert ( | ||
not violations | ||
), f"'Graphene' cannot be included in the GraphQL type name. Violating types: {violations}." |