Closed
Description
Schema:
scalar LocalDate
schema {
query: Query
}
type Query {
birthdaysScalar(dateOfBirth: LocalDate!): [Person]!
birthdaysType(dateOfBirth: DateOfBirth!): [Person]!
}
input DateOfBirth {
date: LocalDate!
}
type Person {
name: String!
dateOfBirth: LocalDate!
}
Code for the request:
GraphQLRequestSerializer.OBJECT_MAPPER
.registerModule(new JavaTimeModule())
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
PersonResponseProjection projection = new PersonResponseProjection().name();
BirthdaysScalarQueryRequest birthdaysScalarQueryRequest = BirthdaysScalarQueryRequest.builder()
.setDateOfBirth(LocalDate.now())
.build();
BirthdaysTypeQueryRequest birthdaysTypeQueryRequest = BirthdaysTypeQueryRequest.builder()
.setDateOfBirth(DateOfBirth.builder().setDate(LocalDate.now()).build())
.build();
GraphQLRequest requestScalar = new GraphQLRequest(birthdaysScalarQueryRequest, projection);
GraphQLRequest requestType = new GraphQLRequest(birthdaysTypeQueryRequest, projection);
System.out.println("Using Scalar: " + requestScalar.toHttpJsonBody());
System.out.println("Using Type: " + requestType.toHttpJsonBody());
Output:
Using Scalar: {"query":"query { birthdaysScalar: birthdaysScalar(dateOfBirth: 2020-12-29){ name } }"}
Using Type: {"query":"query { birthdaysType: birthdaysType(dateOfBirth: { date: \"2020-12-29\" }){ name } }"}
Originally posted by @idegroot in #464 (reply in thread)
Activity
Support custom serialization of parameters in GraphQLOperationRequest #…
Support custom serialization of parameters in GraphQLOperationRequest #…
Kotlin, Scala: Support custom serialization of parameters in GraphQLO…