vulcanjs schemas&& collections

來源:互聯網
上載者:User

標籤:order   tab   create   自動產生   inf   nal   查詢   custom   guests   

一張參考圖

說明

從我們可以方便的看出schmea 能做的事情

  • Generate a GraphQL equivalent of your schema to control your GraphQL API.(產生 graphql api)
  • Control permissions for accessing and modifying data.(存取控制)
  • Generate forms on the client.(client 以及表單產生)
  • Validate form contents on submission.(資料校正)
  • Auto-generate paginated, searchable datatables.(自動產生分頁,查詢)
  • Auto-generate smart cards for displaying individual documents.(智慧卡產生)
  • Add callbacks on document insert or edit.(資料添加,編輯時候的回掉)
參考例子
  • schema

    類似graphql-yogo 以及graphql-js 的schema 定義

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"]  }};
  • 建立collection

    實際上上就是graphql api schema 定義以及解析處理

const Movies = createCollection({  typeName: "Movie",  schema,  resolvers,  mutations});
參考資料

http://docs.vulcanjs.org/schemas.html

    

vulcanjs schemas&& collections

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.