Skip to content

Fixup string bool handling #212

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

Open
wants to merge 33 commits into
base: develop
Choose a base branch
from

Conversation

zntuszntusTW
Copy link

Bool type definition:

Boolean values, either given as the true and false values of JSON, or as the strings "true" and "false".

JSON true and false are fine. but strings "true" and "false" occur error now.

I fix it up

jlouis added 30 commits January 30, 2019 14:28
Start out simple. Assume we cannot return another defer from the defer
we already got. This makes for a relatively simple update to the code
base, where the result of a field closure applies the chain of
functions before it works with the result at a deeper level.
Strategy: keep a chain of changes. Apply this chain when we have value
resolution. Do not cope with the chain dumping a defer for now, but it
is doable given the closure handler anyway. It has to work with the
possibility that the upstream ref changes anyway, so it should be
sound to make this change on top.
Strategy: When a chain returns a defer in the middle, build a new
field closure using the standard closure building tooling. Then ask
the upstream to change its reference to this new closure. Also graft
the completion chain on top of the chain we got from the newly formed
closure.
Special handling of variable coercion is necessary in GraphQL because
if the schema specifies a type [A] then it is valid to use the type A
in its place (for convenience reasons).

However, the code did not contain the correct congruence relations.
Coercion of [A] with [B] is the same as running a coercion of A with
B, hoping that works out.

Add the missing congruence rule, then also alter test cases so they
cover this particular problem. While here, reorder names to be
consistent with the type checker.
Step one of a cleanup. Use a default of `undefined` over the default
of `null` in the input. This opens up making a discrimination between
default values that were never given by the user (`undefined`) and
values which were set to the value `null` by the user.
Rather than passing a not_found on from a failed maps:get/3, handle it
locally in the parameter checker. This avoids a pattern match later on
in the code, which then streamlines the whole thing into a more fluid
flow.

This refactoring is needed for the overarching idea of handling
parameter passing correctly in the system.
The fact everything is a #vardef{} record means we can match on it
early and then handle things naturally in the flow.
We had two checking paths for not-found objects. Coalesce these into a
single path.
The check_param judgement was equivalent to the check_value judgement
except for enum values. Introduce a `sub_context` of either being in
query or variable mode when checking values. Then use this to
discriminate between the enum values, while streamlining every other
flow to the be the same.

This kills a lot of type checker lines and removes a lot of redundancy
in the type checker.
When we have a default parameter, handle that case gracefully and let
the caller decide on how to proceed with default parameters. This
allows default parameters to propagate from a variable into a field,
if the parameter isn't given by the caller. The parameter thus
overrides the underlying game.
The failing test case allows us to properly fix the problem we've seen
internally at Shopgun.
Do not let the Parser override the default value of the record. This
makes sure we only have to fix stuff in one place in the future and
also plugs an error in the system.
Now, a #var{} record is annotated with its underlying default coerced
value if applicable. So when a variable is omitted, and has no default
value, we pick up the coerced value from the underlying arg in the
execution phase. This fixes the bug.
It doesn't hit the case I'm interested in yet, but is a start
Interally, we can have floating point gray scale values. These should
be output as integer-rounded values.
We need a way to supply a colorType. This query is it.
Remove take_arg/3 and just fold the lists:keytake/3 into the caller
directly. While here, identify that we are doing a call to sub with
the same type, which will always succeed, so remove this redundant
check.

This paves the way for correctly handling values.
This fixes a problem in the system where we correctly use defaults for
parameters inside input objects, but don't when they are used in
arguments. This will use defaults correctly in arguments as well, by
augmenting the variable with the underlying default value.
jlouis and others added 3 commits April 14, 2019 19:35
When you default arguments, inject `undefined`. This then allows us to
recast that into a null value later on in the system.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants