简体   繁体   中英

custom scalar type as input arguments in graphql

I defined a custom scalar type: DateTime (based on joda time library) in graphql schema. I see that in the Graphiql UI schema definition and a scalar line at the top of the schema definition.

however, I couldn't find out the syntax of including this as an argument in the query.

for ex, how do I send values of MyDateTimeType in the below query

query {
fetchData(key:"1", dateArg: MyDateTimeType) {
field1
}
}

Actually, it depends on how the MyDateTimeType's coerceInput method is defined. In my case, the coerceInput has a match case statement with StringValue case, so it worked when I passed a String to it. dateArg:"2019-05-30"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM