![GraphQL](http://oflimcy5e.bkt.clouddn.com/graphql-quick-start-thumbnail.png?imageView2/2/w/800)
GraphQL 渐进学习 04-graphql-resolvers-interfaces-接口的使用
目标
代码
步骤
1. 准备测试静态数据
const notices = [{id: 1, content: '这是 notice', noticeTime: 1524710641}]
const reminds = [{id: 1, content: '这是 remind', endTime: 1524710641}]
2. 编写 typeDefs
const typeDefs = `
scalar Date
interface Message {
content: String
}
type Notice implements Message {
content: String
noticeTime: Date
}
type Remind implements Message {
content: String
endTime: Date
}
type Query {
searchInterface (text: String!): Message!
}
`
3. 编写 resolvers