Unknown Argument ValueError Issue - Unable to Diagnose Cause
See original GitHub issueI’ve been having issues with one of my passed mutation arguments that keeps triggering the middleware exception leak checker on graphiql interface load. Migrations and server start are just fine, but loading the url for the interface delivers a "ValueError at /graphql/ Unknown argument “assignee”. " error about.
The following are the directly relevant code snippets.
So I’ve build a “chores” model as such:
class Chore(models.Model):
name = models.TextField(blank=True)
description = models.TextField(blank=True)
isAllDay = models.BooleanField(blank=False)
points = models.IntegerField(blank=False)
status = models.IntegerField(blank=False, null=False)
recurrence_pattern = models.IntegerField(null=False, blank=False)
recurrence_enddate = models.DateTimeField(null=True, blank=False)
deadline = models.DateTimeField(blank=False)
created_by = models.ForeignKey(
'users.User',
related_name='chores_created',
on_delete=models.SET_NULL,
null=True,
)
assigned_to = models.ForeignKey(
'users.User',
related_name='chores_assigned',
on_delete=models.SET_NULL,
null=True,
)
belongs_to = models.ForeignKey(
'households.Household',
related_name="chores",
on_delete=models.SET_NULL,
null=True,
)
Below is the relevant schema portion, including the Type decleration and the InputObjectType I’m utilizing within that same query. I’ve included these portions as I have a strong hunch that the “assignee” value has nothing to do with the actual error, alas, I cannot figure out what it may be.
class ChoreType(DjangoObjectType):
class Meta:
model = Chore
class ResourceCreateInput(graphene.InputObjectType):
name = graphene.String(required = True)
checked = graphene.Boolean(required = True)
class AddChore(graphene.Mutation):
chore = graphene.Field(ChoreType)
class Arguments:
name = graphene.String(),
description= graphene.String(),
isAllDay= graphene.Boolean,
points= graphene.Int(),
status= graphene.Int(),
recurrence_pattern= graphene.Int(),
recurrence_enddate= graphene.DateTime(),
deadline= graphene.DateTime(),
creator= graphene.Int(), # userid
assignee= graphene.Int(), # userid
resources= graphene.List(ResourceCreateInput)
def mutate(self, info, isAllDay, points, status, recurrence_pattern, recurrence_enddate, deadline, creator, assignee = None, resources = None, name = None, description = None):
cUser = User.objects.filter(id=creator).first()
if not cUser:
raise GraphQLError('Invalid Link!')
if assignee != None:
aUser = User.objects.filter(id=assignee).first()
if not aUser:
raise GraphQLError('Invalid Link!')
else:
aUser = None
household = Household.objects.filter(id = 1)
chore = Chore(
name = name,
description = description,
isAllDay = isAllDay,
points = points,
status = status,
recurrence_pattern = recurrence_pattern,
recurrence_enddate = recurrence_enddate,
deadline = deadline,
created_by = cUser,
assigned_to = aUser,
)
chore.save()
if resources != None:
for x in resources:
resource = Resource(
name = x.name,
checked = x.checked,
assigned_to = Chore.objects.get(id__exact = chore.id)
)
resource.save()
return AddChore(
id = chore.id,
)
Issue Analytics
- State:
- Created 4 years ago
- Comments:18 (12 by maintainers)
Top Results From Across the Web
python - Graphene: ValueError: Unknown argument " ...
When i run the application I'm getting the following error: ...schema\__init__.py", line 33, in Mutation create_user = CreateUser. Field() ....
Read more >Fix ValueError: Unknown label type: 'continuous' In scikit- ...
Essentially, the error is telling us that the type of the target variable is continuous which is not compatible with the specific model...
Read more >Troubleshoot Python errors in Azure Functions
This error occurs when a Python function app fails to load a Python module. The root cause for this error is one of...
Read more >Errors | Node.js v19.3.0 Documentation
If an object is passed as message , the text message is generated by calling String(message) . If the cause option is provided,...
Read more >Trap and fix errors in your VLOOKUP in Google Sheets
Incorrect column number – #VALUE! error. Sometimes the third argument of Google Sheets VLOOKUP is indicated incorrectly.
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
Oh, and a big caveat here: This is only setting up CORS here, and CSRF consideration is important when you approach deploying to the wild. This is a good local development solution, but before you deploy, be absolutely sure to read up on both CORS and CSRF, and the security implications involved.
I’ll check it out!
I’m not positive, but you may be in luck. I just now solved my own CORS issues. I have not had a chance to test it live, but I’ve incorporated the changes I made to my own project which solved CORS being a jerk. I’ve submitted a PR to your project and you can try it out. Let me know if it works for you, but don’t see your frontend stuff in the repo, so can’t confirm or deny that it works.
NOTE: You might want to create a new branch to merge the PR into. If you do, and need me to redirect the PR, lemme know.
HEADS UP: You may need to play around with the
CORS_ORIGIN_WHITELIST
settings, but they’re currently handling my own React-Relay frontend just fine.Also note that, in my
Environment.js
file, thenetwork
declaration looks like this:Yeah, that’s one of those dmmit-it’s-named-differently package things.
django-cors-headers
installscorsheaders
and notdjango-cors-headers
, though I believe you should havedjango_cors_headers-3.0.1.dist-info
somewhere in there. If you don’t see either one, double- and triple-check that you’re installing them with yourvenv
activated, and not system-wide.Hand given. 😃 Maybe.
Last note: I’m happy, if I have time, to help on occasion, but from here forward, it’s prolly best if you contact me via github rather than in this issue, to avoid spamming here. I’m addressing this one because I’m just about to add the CORS thingie to the
graphene-django
wiki, so it seems to fit.Cheers! And do let us know if this works or not. Pretty sure that’d be fine here.