diff --git a/gql/dsl.py b/gql/dsl.py index aa4f1559..94d2520e 100644 --- a/gql/dsl.py +++ b/gql/dsl.py @@ -70,14 +70,14 @@ def __init__(self, name, field): self.ast_field = ast.Field(name=ast.Name(value=name), arguments=[]) self.selection_set = None - def get(self, *fields): + def select(self, *fields): if not self.ast_field.selection_set: self.ast_field.selection_set = ast.SelectionSet(selections=[]) self.ast_field.selection_set.selections.extend(selections(*fields)) return self def __call__(self, *args, **kwargs): - return self.get(*args, **kwargs) + return self.args(*args, **kwargs) def alias(self, alias): self.ast_field.alias = ast.Name(value=alias) diff --git a/tests/starwars/test_dsl.py b/tests/starwars/test_dsl.py index d19e19b3..3b9f4b30 100644 --- a/tests/starwars/test_dsl.py +++ b/tests/starwars/test_dsl.py @@ -3,27 +3,6 @@ from gql import Client from gql.dsl import DSLSchema -from .schema import characterInterface, humanType, queryType - - -# We construct a Simple DSL objects for easy field referencing - -# class Query(object): -# hero = queryType.fields['hero'] -# human = queryType.fields['human'] - - -# class Character(object): -# id = characterInterface.fields['id'] -# name = characterInterface.fields['name'] -# friends = characterInterface.fields['friends'] -# appears_in = characterInterface.fields['appearsIn'] - - -# class Human(object): -# name = humanType.fields['name'] - - from .schema import StarWarsSchema @@ -40,7 +19,7 @@ def test_hero_name_query(ds): name } '''.strip() - query_dsl = ds.Query.hero( + query_dsl = ds.Query.hero.select( ds.Character.name ) assert query == str(query_dsl) @@ -56,10 +35,10 @@ def test_hero_name_and_friends_query(ds): } } '''.strip() - query_dsl = ds.Query.hero( + query_dsl = ds.Query.hero.select( ds.Character.id, ds.Character.name, - ds.Character.friends( + ds.Character.friends.select( ds.Character.name, ) ) @@ -79,12 +58,12 @@ def test_nested_query(ds): } } '''.strip() - query_dsl = ds.Query.hero( + query_dsl = ds.Query.hero.select( ds.Character.name, - ds.Character.friends( + ds.Character.friends.select( ds.Character.name, ds.Character.appears_in, - ds.Character.friends( + ds.Character.friends.select( ds.Character.name ) ) @@ -98,7 +77,7 @@ def test_fetch_luke_query(ds): name } '''.strip() - query_dsl = ds.Query.human.args(id="1000").get( + query_dsl = ds.Query.human(id="1000").select( ds.Human.name, ) @@ -172,7 +151,7 @@ def test_fetch_luke_aliased(ds): name } '''.strip() - query_dsl = ds.Query.human.args(id=1000).alias('luke').get( + query_dsl = ds.Query.human.args(id=1000).alias('luke').select( ds.Character.name, ) assert query == str(query_dsl)