Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scalar Type Json is not working when we are using type "Input" #109

Open
GRajaMca opened this issue Jun 7, 2023 · 0 comments
Open

Scalar Type Json is not working when we are using type "Input" #109

GRajaMca opened this issue Jun 7, 2023 · 0 comments

Comments

@GRajaMca
Copy link

GRajaMca commented Jun 7, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant