You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Scenario:
When I have a scenario where I need to send one attribute with key value pair data to a graphql server, I use the Scalar type as Json in the setup and declare the same thing in the graphql schema.
However, during testing, I discovered that the map value is correct until the ObjectScalar.class properly and that the value is being put in the LinkedHashMap, but when the request reaches the controller, it becomes empty.
Note:
When there is read operation from graphql Server then it works fine
To Reproduce
Spring Boot Version : 2.7.5
GraphQL : spring-boot-starter-graphql
GraphQL Scalar Extender Version : graphql-java-extended-scalars-20.2 GraphqlSchema
Describe the bug
Scenario:
When I have a scenario where I need to send one attribute with key value pair data to a graphql server, I use the Scalar type as Json in the setup and declare the same thing in the graphql schema.
However, during testing, I discovered that the map value is correct until the ObjectScalar.class properly and that the value is being put in the LinkedHashMap, but when the request reaches the controller, it becomes empty.
Note:
When there is read operation from graphql Server then it works fine
To Reproduce
Spring Boot Version : 2.7.5
GraphQL : spring-boot-starter-graphql
GraphQL Scalar Extender Version : graphql-java-extended-scalars-20.2
GraphqlSchema
scalar JSON input RuleInput { ruleName: String ruleConfiguration: JSON } type Mutation { createRule(ruleInput: RuleInput): JSON }
Java DTO Class
import java.util.Map; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @Data @NoArgsConstructor @AllArgsConstructor public class RuleInput { private String ruleName; private Map<String, Object> ruleConfiguration; }
GraphQL Configuration
import graphql.scalars.ExtendedScalars; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.graphql.execution.RuntimeWiringConfigurer; @Configuration public class GraphQLConfiguration { @Bean protected RuntimeWiringConfigurer runtimeWiringConfigurer() { return builder -> builder .scalar(ExtendedScalars.Json); } }
Controller
@Slf4J @Controller public class RuleController { @MutationMapping public Mono<Long> createRule(@Argument(name = "ruleInput") RuleInput ruleInput) { log.info("Input :{}", ruleInput); // except the Map value, rest all values are coming correctly. return this.ruleService.createOptimizationRule(ruleInput); } }
Note :
stackoverflow discussion link : https://stackoverflow.com/questions/76421824/scalar-type-json-is-not-working-when-we-are-using-type-input-for-mutation
The text was updated successfully, but these errors were encountered: