[英]How to specify DateTime in GraphQL schema?
I am building my GraphQL schema for my project and one of my models has a DateTime format.我正在为我的项目构建我的 GraphQL 架构,我的一个模型具有 DateTime 格式。
How do I write out date formats on my GraphQL schema?如何在我的 GraphQL 架构上写出日期格式?
I tried DateTime or Date but nothing shows up.我尝试了 DateTime 或 Date,但没有显示任何内容。
This is the model:这是 model:
public Integer Id;
public String name;
public String description;
public LocalDate birthDate;
This is what's in my GraphQL schema:这是我的 GraphQL 架构中的内容:
type Pet {
id: ID!
name: String!
description: String
birthDate: DateTime
}
But it says:但它说:
Unknown type DateTime
未知类型日期时间
Create a custom scalar for your types that is not recognized by your framework.为您的框架无法识别的类型创建自定义标量。
I am not sure which graphql-java based framework you are using.我不确定您使用的是哪种基于 graphql-java 的框架。 I assume you are using the official Spring for GraphQL from Spring team.
我假设您正在使用来自 Spring 团队的 GraphQL 的官方 Spring 。
RuntimeWiring
bean, check here .RuntimeWiring
bean 中注册它,在此处检查。 If you are using Saclars in other graphql-java based frameworks(GraphQL Java, GraphQL Java Kickstart, GraphQL Kotlin, GraphQL SPQR, Netflix DGS etc) and spring integrations, check my Spring GraphQL Sample . If you are using Saclars in other graphql-java based frameworks(GraphQL Java, GraphQL Java Kickstart, GraphQL Kotlin, GraphQL SPQR, Netflix DGS etc) and spring integrations, check my Spring GraphQL Sample . The back-end principle is similar, just some different config.
后端原理类似,只是一些不同的配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.