Field argument names conflict with constructor arguments
See original GitHub issueThe current implementation of Field
’s constructor handles arguments named name
or source
that are of Argument
type but does not do the same for the rest of them (e.g. description
or required
).
For example, this fails as follows:
import graphene
class Query(graphene.ObjectType):
answer = graphene.Int(description=graphene.Int())
def resolve_answer(self, info, description):
return description
schema = graphene.Schema(query=Query)
result = schema.execute('{ answer(description: 42) }')
assert result.data
assert result.data['answer'] == 42
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Conflicts between member names and constructor argument ...
In the problem at hand, the arguments x , y , width , and height to the non-default constructor for class A shadow...
Read more >Ensure that local variable/parameter names do not conflict ...
Title Ensure that local variable/parameter names do not conflict with Field names inside a 'with' statement. Description
Read more >@NoArgsConstructor, @RequiredArgsConstructor ...
@AllArgsConstructor generates a constructor with 1 parameter for each field in your class. Fields marked with @NonNull result in null checks on those...
Read more >Change Signature refactoring - ReSharper - JetBrains
This refactoring combines several modifications that can be made to signatures of methods, constructors, properties, and indexers.
Read more >Strict mode - JavaScript - MDN Web Docs
Strict mode requires that function parameter names be unique. In sloppy mode, the last duplicated argument hides previous identically-named ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m having second thoughts on this.
The use case can actually be handled by:
Checking all the “metadata arguments” in Field’s constructor does not seem scalable (it would be 8 if’s with the current signature). A simple mention in the docs that arguments with “reserved” names can be specified in
args
instead would probably suffice.PR created to update docs: https://github.com/graphql-python/graphene/pull/1170