question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Field argument names conflict with constructor arguments

See original GitHub issue

The 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:closed
  • Created 4 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tdiamcommented, Oct 2, 2019

I’m having second thoughts on this.

The use case can actually be handled by:

answer = graphene.Int(args={'description': graphene.Int()})

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.

0reactions
jkimbocommented, Apr 1, 2020
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found