亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    聊一聊基于webman的GraphQL實(shí)現(xiàn)

    本篇文章給大家?guī)砹岁P(guān)于GraphQL的相關(guān)知識,其中主要跟大家聊一聊有關(guān)基于webman的GraphQL實(shí)現(xiàn),感興趣的朋友下面一起來看一下吧,希望對大家有幫助。

    基于PHPGraphQL由于加載指令(directive)和解析schema的開銷較大,性能不是很理想。webman是常駐內(nèi)存的,所以GraphQLwebman上的性能表現(xiàn)非常不錯(cuò)。

    GrahpQL 是基于YiAdmin的一個(gè)模塊,用于快速創(chuàng)建GraphQL服務(wù),可以開啟多個(gè)服務(wù),模塊內(nèi)置了多個(gè)指令用于快速開發(fā)api接口。

    調(diào)試接口地址:/graphql-dev/api/服務(wù)名稱
    正式接口地址:/graphql-api/服務(wù)名稱
    后臺接口管理可以建立接口名稱與Query的映射關(guān)系,通過接口名稱訪問以簡化前端輸入,curl -X POST -d "{"variables": VARIABLES}" -H "Content-type:application/json" "HOST/graphql-api/SERVER_NAME?api=接口名稱"
    零依商城 是基于YiAdmin的uniapp商城系統(tǒng),Api接口基于GrahpQL進(jìn)行了重構(gòu)。

    聊一聊基于webman的GraphQL實(shí)現(xiàn)

    例如有如下 schema

    // Type type Article {     id: Int     category_id: Int     title: String     description: String     created_at: Int     create_time: String @alias(key: "created_at") @date     status: Int }  type ArticlePagination {     pagination: Pagination     data: [Article] }
    登錄后復(fù)制

    通過模型獲取記錄,支持模型 scope

    // Query "通過文章ID獲取文章" article(     "文章ID"     id: Int! @eq ): Article @model(name: "\app\test\model\api\ArticleModel", scopes: ["published"]) @find
    登錄后復(fù)制

    支持分頁 paginate

    articles: ArticlePagination @model(name: "\app\test\model\api\ArticleModel", scopes: ["published"]) @paginate(perPage: 15)
    登錄后復(fù)制

    查詢條件 where

    articles(     title: String ): ArticlePagination @model(name: "\app\test\model\api\ArticleModel", scopes: ["published"]) @where(value: { title: ["like", "$title"] }) @paginate(perPage: 15)
    登錄后復(fù)制

    延遲加載 defer

    // Type type article {     ...     category: Category @defer(resolver: "\app\test\loaders\Cms@getCategoryById", keys: "category_id") }  type Category {     id: Int     parent_id: Int     title: String     parent: Category @defer(resolver: "\app\test\loaders\Cms@getCategoryById", keys: "parent_id") }
    登錄后復(fù)制

    除此以外,還有包括auth權(quán)限管理、resolver自定義處理方法、date時(shí)間格式化、validate驗(yàn)證器、water打碼脫敏、upper轉(zhuǎn)大寫、lower轉(zhuǎn)小寫等各種指令。
    聊一聊基于webman的GraphQL實(shí)現(xiàn)

    推薦學(xué)習(xí):《PHP視頻教程》

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號