Skip to content

ObjectScalar/JsonScalar types in POJO and schema #394

Answered by neerajsu
neerajsu asked this question in Q&A
Discussion options

You must be logged in to vote

Nevermind I figured out the problem myself.

I had to just add the following bean inside a configuration file

@Bean
public GraphQLScalarType jsonScalar() {
        return ExtendedScalars.Json;
}

ExtendedScalars is taken from this project --> https://github.com/graphql-java/graphql-java-extended-scalars

Then make the following changes to the .graphqls file

type CopyJob {
    id: String!
    name: String!
    jobAssets: [JobAsset]
}

type JobAsset {
    jobAssetIdentifier: String!
    initialGlobalSeason: String!
    copy: JSON!

}

scalar JSON

type Query {
    getCopyJob(id: String!) : CopyJob
}

Changes to graphql pojo

@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
public class Co…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by vojtapol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #394 on December 21, 2020 15:48.