dotansimha / dotansimha/graphql-code-generator-community

[java-resolvers] Support for getting source casted to a class through generated interface

Open
#176 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
137
Forks
195
Avg merge
6h 20m
Merged PRs (30d)
16

Description

**Is your feature request related to a problem? Please describe.**

Currently we have to manually create methods in the implementation of an interface for getting the source casted to class that we have defined as a mapper for the schema type. It would be nicer if such code was generated to the resolver interface.

**Describe the solution you'd like**
If we have defined in the config file a following mapper:
```
mappers:
User: org.something.model.DatabaseUser
```

and use the `java-resolvers` plugin to generate resolver interface, we would like to get the following generated code:

```
public interface User {

public DataFetcher getName();

default DatabaseUser getSource(
DataFetchingEnvironment environment) {
return environment.getSource();
}
}
```

where the getSource is a new function that can be used to get the source as the correct type.

**Describe alternatives you've considered**
Currently, we manually implement the getSource function for each implementation. Haven't found a different solution that could solve this issue.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.