從上圖咱們能夠方便的看出schmea 能作的事情html
相似graphql-yogo 以及graphql-js 的schema 定義api
const schema = { // default properties _id: { type: String, optional: true, canRead: ["guests"] }, createdAt: { type: Date, optional: true, canRead: ["guests"], onCreate: ({ newDocument, currentUser }) => { return new Date(); } }, userId: { type: String, optional: true, canRead: ["guests"], resolveAs: { fieldName: "user", type: "User", resolver: (movie, args, context) => { return context.Users.findOne( { _id: movie.userId }, { fields: context.Users.getViewableFields( context.currentUser, context.Users ) } ); }, addOriginalField: true } }, // custom properties name: { label: "Name", type: String, optional: true, canRead: ["guests"], canCreate: ["members"], canUpdate: ["members"] }, year: { label: "Year", type: String, optional: true, canRead: ["guests"], canCreate: ["members"], canUpdate: ["members"] }, review: { label: "Review", type: String, optional: true, control: "textarea", canRead: ["guests"], canCreate: ["members"], canUpdate: ["members"] } };
實際上上就是graphql api schema 定義以及解析處理ui
const Movies = createCollection({ typeName: "Movie", schema, resolvers, mutations });