-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Field aliases #10
Comments
EDIT: No, it does not. And I am blind!I poked around a bit dsl.py class ResolvedBinding(NamedTuple):
...
attr_name_alias: str
...
class GraphQLQueryConstructor(NamedTuple):
...
def prepare_bindings(self, expr: Expr) -> Mapping[str, Iterable[ResolvedBinding]]:
...
rv[resolved_expr].append(resolved_input)
return rv
def resolve_binding(self, typ: Type[Any], field: FieldReference, alias: Optional[str]) -> ResolvedBinding:
...
return ResolvedBinding(attr_name=overrider(name),
attr_name_alias=typ._field_defaults.get(attr_name),
input_attr_name=alias if alias else attr_name,
type_name=type_name,
is_optional=is_optional) translator.py def translate_begin_type(x: Token, bindings: Mapping[Any, Any]) -> str:
if bindings:
expr_bindings = next(iter(bindings))
python_name_alias = expr_bindings.attr_name_alias
all_input_bindings = chain.from_iterable(bindings.values())
...
if python_name_alias:
return f'{python_name_alias}{x.python_name}{vars}{{'
return f'{x.python_name}{vars}{{'
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it possible to set aliases to fields?
Such as this
I was looking through the source code and foundgraphql-dsl/graphql_dsl/dsl.py
Line 185 in 6bcd393
What isBinding.variable_alias
meant for?If this is not already possible, maybe reading
NamedTuple._field_defaults
should suffice? Like so:Or might this already be on the roadmap?
EDIT:
Ah ok
Binding.variable_alias
andinput_attr_name=alias if alias else attr_name,
is for* AS * 'my_alias'
The text was updated successfully, but these errors were encountered: