(
self,
ctx: Context,
name: str,
graphql: GraphQLInputField | GraphQLArgument,
parent: "_ObjectField | None" = None,
)
| 547 | """Input object field or object field argument.""" |
| 548 | |
| 549 | def __init__( |
| 550 | self, |
| 551 | ctx: Context, |
| 552 | name: str, |
| 553 | graphql: GraphQLInputField | GraphQLArgument, |
| 554 | parent: "_ObjectField | None" = None, |
| 555 | ) -> None: |
| 556 | self.ctx = ctx |
| 557 | self.graphql_name = name |
| 558 | self.graphql = graphql |
| 559 | |
| 560 | self.name = format_name(name) |
| 561 | self.named_type = get_named_type(graphql.type) |
| 562 | self.parent_return_type: TypeName | None = ( |
| 563 | get_named_type(parent.graphql.type).name if parent else None |
| 564 | ) |
| 565 | self.parent_object_name: TypeName | None = ( |
| 566 | parent.parent_name if parent else None |
| 567 | ) |
| 568 | |
| 569 | # Read @expectedType directive from the argument's AST node. If an old |
| 570 | # schema view is being generated from the unified-ID schema and this is |
| 571 | # an `id` argument on a typed field, fall back to the field return type |
| 572 | # so the legacy signature can still use `FooID`. |
| 573 | self.expected_type = expected_type_name(ctx.schema, graphql.ast_node) |
| 574 | if ( |
| 575 | self.expected_type is None |
| 576 | and ctx.legacy_sdk_compat |
| 577 | and name == "id" |
| 578 | and self.parent_return_type not in (None, "Node") |
| 579 | ): |
| 580 | self.expected_type = self.parent_return_type |
| 581 | |
| 582 | # On object type fields, don't replace ID scalar with object |
| 583 | # only if field name is `id` and the expected type matches |
| 584 | # the output type (e.g., `file(id: ID! @expectedType(name: "File")) -> File`). |
| 585 | convert_id = not ( |
| 586 | name == "id" and self.expected_type == self.parent_return_type |
| 587 | ) |
| 588 | |
| 589 | self.type = format_input_type( |
| 590 | graphql.type, |
| 591 | convert_id, |
| 592 | self.expected_type, |
| 593 | ctx.legacy_sdk_compat, |
| 594 | ) |
| 595 | self.is_self = self.type == self.parent_object_name |
| 596 | self.description = graphql.description |
| 597 | self.has_default = graphql.default_value is not Undefined |
| 598 | reason = getattr(graphql, "deprecation_reason", None) |
| 599 | self.deprecated = rewrite_notice(reason, prefix="", suffix="") |
| 600 | |
| 601 | default_value = graphql.default_value |
| 602 | self.default_is_mutable = isinstance(default_value, list) |
| 603 | |
| 604 | if not is_required_type(graphql.type) and not self.has_default: |
| 605 | default_value = None |
| 606 | self.has_default = True |
nothing calls this directly
no test coverage detected