aoudiamoncef / apollo-client-maven-plugin

Generate a Java/Kotlin GraphQL client based on introspection data and predefined queries.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hi, is there an easy way to map GraphQL Int to Java Long type

git4x opened this issue · comments

commented

Let's say the schema defines:
create_item("The new item's name." item_name: String, "The unique identifier." board_id: Int!, "The column values of the new item." column_values: JSON): Item

and the mutation is like:
mutation CreateItem ($boardId: Int!, $itemName: String!, $columnValues: JSON!) {create_item (board_id: $boardId, item_name: $itemName, column_values: $columnValues) {id}}

the Java bean (POJO) generated by the plugin is like:
public CreateItemMutation(Integer boardId, String itemName, Object columnValues) { this.boardId = boardId; this.itemName = itemName; this.columnValues = columnValues; }

So my question is how I can have the generated POJO which maps the boardId as Long type instead of integer type?

public CreateItemMutation(Long boardId, String itemName, Object columnValues) { this.boardId = boardId; this.itemName = itemName; this.columnValues = columnValues; }

I see the Gradle plugin has a configuration: mapScalar("Int", "Long"), does the Maven plugin has an equivalent one?

Update:
I tried:
<customScalarsMapping> <Int>java.lang.Long</Int> </customScalarsMapping>

but get error:

Execution default of goal com.github.aoudiamoncef:apollo-client-maven-plugin:5.0.0:generate failed: Apollo: unknown custom scalar(s) in customScalarsMapping: Int -> [Help 1]

Thank you!

Hi @git4x have any updates about this ?

commented

@aoudiamoncef uh, no. We used other ways to map the GraphQL schema to Java models by that time. Thanks!