Fields with scalars should support projections#197
Merged
berngp merged 1 commit intofeature/basic-type-projectsfrom Jul 26, 2021
Merged
Fields with scalars should support projections#197berngp merged 1 commit intofeature/basic-type-projectsfrom
berngp merged 1 commit intofeature/basic-type-projectsfrom
Conversation
50938b6 to
1189200
Compare
Current Behavior
================
The _Client API codegen_ will not generate projection types for _scalars_. Let's say we have the following schema:
```
type Query {
ping: Foo
}
type Foo {
someField(arg: Boolean): Long
}
scalar Long
```
According to the schema we should expect a _someField projection_, but currently this is not the case.
Suggested Improvement
=====================
When generating the root projections, as well as sub-projections, we
need to consider the _fields_ with basic types that present input arguments.
To be more specific, and leveraging the schema mentioned above, the `SomeFieldProjectionRoot` _projection type_
should include a `ping(Boolean arg)` method definition.
The changes on this PR will generate the following `ping(Boolean arg)` method...
```
public SomeField_PingProjection ping(Boolean arg) {
SomeField_PingProjection projection = new SomeField_PingProjection(this, this);
getFields().put("ping", projection);
getInputArguments().computeIfAbsent("ping", k -> new ArrayList<>());
InputArgument argArg = new InputArgument("arg", arg);
getInputArguments().get("ping").add(argArg);
return projection;
}
```
In addition to the `ping()` method that will already exist in the `SomeFieldProjectionRoot`, such as the one
below.
```
public SomeField_PingProjection ping() {
SomeField_PingProjection projection = new SomeField_PingProjection(this, this);
getFields().put("ping", projection);
return projection;
}
```
1189200 to
c09781a
Compare
srinivasankavitha
approved these changes
Jul 26, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current Behavior
The Client API codegen will not generate projection types for scalars. Let's say we have the following schema:
According to the schema we should expect a someField projection, but currently this is not the case.
Suggested Improvement
When generating the root projections, as well as sub-projections, we
need to consider the fields with basic types that present input arguments.
To be more specific, and leveraging the schema mentioned above, the
SomeFieldProjectionRootprojection typeshould include a
ping(Boolean arg)method definition.The changes on this PR will generate the following
ping(Boolean arg)method...In addition to the
ping()method that will already exist in theSomeFieldProjectionRoot, such as the onebelow.