Comments (7)
Hi @ckwong-jebsen
You have to create your own adapter:
val longCustomTypeAdapter = object : CustomTypeAdapter<Long> {
override fun encode(value: Long): CustomTypeValue<*> {
return value.toString() as CustomTypeValue<String>
}
override fun decode(value: CustomTypeValue<*>): Long {
return (value.value as BigDecimal).toLong()
}
}
from apollo-client-maven-plugin.
<customTypeMap>
<DateTime>java.time.LocalDateTime</DateTime>
<GeoJSONString>java.lang.String</GeoJSONString>
</customTypeMap>
I also encountered the same problem. When it is generating CustomType.java file, it doesn't include the GeoJSONString
CustomType.
Here's a snippet of my schema.json file
{
...
},
{
"kind": "SCALAR",
"name": "GeoJSONString",
"description": "A GeoJSON formatted String.\n\n\nCurrently only supports Point GeoJSON type.\n\ne.g.\n\n\"{\n \"type\": \"Point\",\n \"coordinates\": [125.6, 10.1]\n}\"\n\n\nSupport for LineString GeoJSON type is under development.\n\n\n\nPlease see https://geojson.org for more info.",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
...
}
I also tried your suggestion in providing a CustomTypeAdapter but still didn't include the GeoJSONString CustomTypeMap in CustomType.java file upon generation.
public enum CustomType implements ScalarType {
DATETIME {
@Override
public String typeName() {
return "DateTime";
}
@Override
public String className() {
return "java.time.LocalDateTime";
}
},
ID {
@Override
public String typeName() {
return "ID";
}
@Override
public String className() {
return "java.lang.String";
}
}
}
Please advise if I did something wrong on my end or recommend how should I be able to fix it.
By the way, appreciate what you did with this plugin, it's a huge lifesaver for one of the projects that I'm involved in.
from apollo-client-maven-plugin.
Hi @dryst0,
have you added adapter's to your ApolloClient instance ?
ApolloClient.builder()
.serverUrl(serverUrl)
.addCustomTypeAdapter(CustomType.DATE, dateCustomTypeAdapter)
.build()
from apollo-client-maven-plugin.
Hi @dryst0,
have you added adapter's to your ApolloClient instance ?ApolloClient.builder() .serverUrl(serverUrl) .addCustomTypeAdapter(CustomType.DATE, dateCustomTypeAdapter) .build()
Yes, I have also added the custom type adapters to my apolloClient
ApolloClient apolloClient = ApolloClient.builder().serverUrl(impressionsEndpoint)
.addCustomTypeAdapter(CustomType.DATETIME, dateTimeAdapter)
.addCustomTypeAdapter(CustomType.GEOJSONSTRING, geojsonCustomTypeAdapter).okHttpClient(client).build();
Only CustomType.DATETIME
was included in the auto-generated class file. CustomType.GEOJSONSTRING
doesn't exist and therefore my build is failing.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project common: Compilation failure
[ERROR] <redacted> cannot find symbol
[ERROR] symbol: variable GEOJSONSTRING
[ERROR] location: class m.m.m.graphql.client.type.CustomType
from apollo-client-maven-plugin.
I'll try to add a test for this case in next release.
I think that you have to report this issue to the main project which is Apollo Android
It could be an issue with Apollo compiler
thanks
from apollo-client-maven-plugin.
I think that you have to report this issue to the main project which is Apollo Android
Alright. I'll also raise an issue there as well.
Do you have any suggestions to work around this issue in the meanwhile?
I am thinking of copying the generated-sources back to main directory and manually adding the CustomType.GEOJSONSTRING
in CustomType.java and commenting out this maven plugin for now until the issue gets resolved.
Thank you also for the quick response.
from apollo-client-maven-plugin.
Just wanted to refer the post-mortem report regarding the issue I've raised here.
apollographql/apollo-kotlin#2721 (comment)
TLDR; Multiple execution section under the same plugin which writes the output on the same directory and overwrites the CustomType.java
Also, thanks for all the help!
from apollo-client-maven-plugin.
Related Issues (20)
- Java classes not generated HOT 3
- apollo-client-maven-plugin:4.0.5:generate failed.: NullPointerException while generating Sources using Plugin HOT 14
- Migration missed Getters and Builder as default builder HOT 7
- Hi, is there an easy way to map GraphQL Int to Java Long type HOT 2
- How to get response raw json ? HOT 1
- Java 19 HOT 3
- Unable to get code to compile and resolve in kotlin HOT 1
- how to modify model class created by graph -ql ? HOT 2
- Upgrading from Plugin Version 3.3.1 HOT 1
- Test cases are not executed in apollo-client-maven-plugin-tests HOT 1
- How to skip generating classes for queries? HOT 1
- Generate full query through schema
- deleted
- GraphQL Client not generating to target sources.
- Kotlin Support for Apollo Client plugin
- Upgrading to 7.1.0 throws an error about operationOutput HOT 4
- Is it possible to generate the code from a schema file (graphqls) and not introspection result? HOT 1
- Generate sources error Service.getEnabled is null HOT 4
- Migration to Gradle
- scalarsMapping documentation HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo-client-maven-plugin.