How to regist PageInfo in Schema #371
Unanswered
ferrisyang
asked this question in
Q&A
Replies: 2 comments 6 replies
-
|
I found a solution: @DgsScalar(name = "PageInfo")
public class PageInfoScalar implements Coercing<PageInfo, PageInfo> {
private static final ObjectMapper objectMapper = new ObjectMapper();
@Override
public PageInfo serialize(Object dataFetcherResult) throws CoercingSerializeException {
if (dataFetcherResult instanceof PageInfo) {
return (PageInfo) dataFetcherResult;
}
throw new CoercingSerializeException("Not a valid PageInfo");
}
@Override
public PageInfo parseValue(Object input) throws CoercingParseValueException {
return null;
}
@Override
public PageInfo parseLiteral(Object input) throws CoercingParseLiteralException {
return null;
}
}And in schema, add |
Beta Was this translation helpful? Give feedback.
6 replies
-
|
You should mapping //build.gradle.kts
@OptIn(kotlin.ExperimentalStdlibApi::class)
tasks.withType<com.netflix.graphql.dgs.codegen.gradle.GenerateJavaTask> {
generateClient = true
typeMapping = mutableMapOf<String, String>(
//"JSON" to "graphql.scalars.object.JsonScalar",
//"Object" to "graphql.scalars.object.ObjectScalar",
//"Long" to "kotlin.Long",
"PageInfo" to "graphql.relay.PageInfo",
"Edge" to "graphql.relay.Edge",
"Connection" to "graphql.relay.Connection"
)
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Use Relay style for pagination, and write PageInfo type in Schema, will get error [The field type 'PageInfo' is not present] when start the program.
How to regist PageInfo type in Schema?
Beta Was this translation helpful? Give feedback.
All reactions