<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ## 插件 > **提醒**:本章僅適用于 `@nestjs/apollo` 驅動程序。 插件能讓你通過響應某些特定事件時執行自定義操作,來擴展 Apollo Server 的核心功能。現在,這些事件對應 GraphQL 請求生命周期的各個階段,以及 Apollo Server 本身的啟動階段(參見[這里](https://www.apollographql.com/docs/apollo-server/integrations/plugins/))。比如,一個基本的日志插件可能會記錄每一個發送給 Apollo Server 請求的相關 GraphQL 查詢字符串。 ### 自定義插件 創建插件,首先要聲明一個用 `@Plugin` 裝飾器注釋的類,這個裝飾器是從 `@nestjs/graphql` 包里導出的。還有,為了更好的使用代碼自動補全功能,我們要從 `Apollo-server-plugin-base` 包中實現 `ApolloServerPlugin` 這個接口。 ```typescript import { Plugin } from '@nestjs/graphql'; import { ApolloServerPlugin, GraphQLRequestListener, } from 'apollo-server-plugin-base'; @Plugin() export class LoggingPlugin implements ApolloServerPlugin { requestDidStart(): GraphQLRequestListener { console.log('Request started'); return { willSendResponse() { console.log('Will send response'); }, }; } } ``` 有了下面這段代碼,我們就可以將 `LoggingPlugin` 注冊為一個提供者。 ```typescript @Module({ providers: [LoggingPlugin], }) export class CommonModule {} ``` Nest 會自動實例化一個插件并將其應用于 Apollo 服務。 ### 使用外部插件 有幾個開箱即用的插件。使用一個現成的插件,只需將它導入并加入到 `plugins` 數組即可: ```typescript GraphQLModule.forRoot({ // ... plugins: [ApolloServerOperationRegistry({ /* options */})] }), ``` > `ApolloServerOperationRegistry` 插件是從 `apollo-server-plugin-operation-registry` 包里導出的。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看