-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing empty directives in DSL nodes (#448)
- Loading branch information
1 parent
c5a164c
commit 632ec96
Showing
2 changed files
with
69 additions
and
3 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
59 changes: 59 additions & 0 deletions
59
tests/regressions/issue_447_dsl_missing_directives/test_dsl_directives.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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from gql import Client | ||
from gql.dsl import DSLFragment, DSLQuery, DSLSchema, dsl_gql | ||
|
||
schema_str = """ | ||
type MonsterForm { | ||
sprites: MonsterFormSprites! | ||
} | ||
union SpriteUnion = Sprite | CopyOf | ||
type Query { | ||
monster: [Monster!]! | ||
} | ||
type MonsterFormSprites { | ||
actions: [SpriteUnion!]! | ||
} | ||
type CopyOf { | ||
action: String! | ||
} | ||
type Monster { | ||
manual(path: String!): MonsterForm | ||
} | ||
type Sprite { | ||
action: String! | ||
} | ||
""" | ||
|
||
|
||
def test_issue_447(): | ||
|
||
client = Client(schema=schema_str) | ||
ds = DSLSchema(client.schema) | ||
|
||
sprite = DSLFragment("SpriteUnionAsSprite") | ||
sprite.on(ds.Sprite) | ||
sprite.select( | ||
ds.Sprite.action, | ||
) | ||
copy_of = DSLFragment("SpriteUnionAsCopyOf") | ||
copy_of.on(ds.CopyOf) | ||
copy_of.select( | ||
ds.CopyOf.action, | ||
) | ||
|
||
query = ds.Query.monster.select( | ||
ds.Monster.manual(path="").select( | ||
ds.MonsterForm.sprites.select( | ||
ds.MonsterFormSprites.actions.select(sprite, copy_of), | ||
), | ||
), | ||
) | ||
|
||
q = dsl_gql(sprite, copy_of, DSLQuery(query)) | ||
|
||
client.validate(q) |