-
Notifications
You must be signed in to change notification settings - Fork 27
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
Fix get parent field #5
Changes from all commits
45d834b
d551f6c
5792bce
ea4edaa
7ba7b5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,16 @@ function util.bind1(func, x) | |
end | ||
end | ||
|
||
function util.getParentField(context, name, count) | ||
count = count == nil and 1 or count | ||
local obj = context.objects[#context.objects - count] | ||
if obj.__type == 'List' then | ||
return obj.ofType.fields[name] | ||
else | ||
return obj.fields[name] | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we could default There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'll fix that |
||
|
||
function util.coerceValue(node, schemaType, variables) | ||
variables = variables or {} | ||
|
||
|
@@ -58,7 +68,7 @@ function util.coerceValue(node, schemaType, variables) | |
error('Unknown input object field "' .. field.name .. '"') | ||
end | ||
|
||
return util.coerceValue(schemaType.fields[field.name].kind, field.value, variables) | ||
return util.coerceValue(field.value, schemaType.fields[field.name].kind, variables) | ||
end) | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
Field "field" is not defined on type "[Parent]"
here would be better (brackets to indicate List type).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see where you are going but i think the message is correct now since "field" is part of the "parent" definition and has nothing to do with the list. For example:
"is_complete" is a property of "task" type
sounds good but"is_complete" is a property of "[task]" type
is a bit wired