<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ### 遷移到 v10 本文提供了一組從`@nestjs/graphql`版本 9 遷移到版本 10 的指南。這個主要版本版本的重點是提供一個更輕量級的、與平臺無關的核心庫。 #### 引入“驅動程序”包[#](https://docs.nestjs.com/graphql/migration-guide#introducing-driver-packages) 在最新版本中,我們決定將`@nestjs/graphql`包分解為幾個單獨的庫,讓您選擇是否使用 Apollo (`@nestjs/apollo`)、Mercurius (`@nestjs/mercurius` ) 或項目中的另一個 GraphQL 庫。 這意味著現在您必須明確指定您的應用程序將使用什么驅動程序。 ~~~typescript // Before import { Module } from '@nestjs/common'; import { GraphQLModule } from '@nestjs/graphql'; @Module({ imports: [ GraphQLModule.forRoot({ autoSchemaFile: 'schema.gql', }), ], }) export class AppModule {} // After import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo'; import { Module } from '@nestjs/common'; import { GraphQLModule } from '@nestjs/graphql'; @Module({ imports: [ GraphQLModule.forRoot<ApolloDriverConfig>({ driver: ApolloDriver, autoSchemaFile: 'schema.gql', }), ], }) export class AppModule {} ~~~ #### 插件[#](https://docs.nestjs.com/graphql/migration-guide#plugins) Apollo Server 插件允許您執行自定義操作以響應某些事件。 由于這是 Apollo 獨有的功能,我們將其從`@nestjs/graphql` 移至新創建的`@nestjs/apollo` 包,因此您必須更新應用程序中的導入。 ~~~typescript // Before import { Plugin } from '@nestjs/graphql'; // After import { Plugin } from '@nestjs/apollo'; ~~~ #### 指令[#](https://docs.nestjs.com/graphql/migration-guide#directives) `schemaDirectives` 功能已替換為`@graphql-tools/schema`包 v8 中的新 [Schema 指令 API](https://www.graphql-tools.com/docs/schema-directives)。 ~~~typescript // Before import { SchemaDirectiveVisitor } from '@graphql-tools/utils'; import { defaultFieldResolver, GraphQLField } from 'graphql'; export class UpperCaseDirective extends SchemaDirectiveVisitor { visitFieldDefinition(field: GraphQLField<any, any>) { const { resolve = defaultFieldResolver } = field; field.resolve = async function (...args) { const result = await resolve.apply(this, args); if (typeof result === 'string') { return result.toUpperCase(); } return result; }; } } // After import { getDirective, MapperKind, mapSchema } from '@graphql-tools/utils'; import { defaultFieldResolver, GraphQLSchema } from 'graphql'; export function upperDirectiveTransformer( schema: GraphQLSchema, directiveName: string, ) { return mapSchema(schema, { [MapperKind.OBJECT_FIELD]: (fieldConfig) => { const upperDirective = getDirective( schema, fieldConfig, directiveName, )?.[0]; if (upperDirective) { const { resolve = defaultFieldResolver } = fieldConfig; // Replace the original resolver with a function that *first* calls // the original resolver, then converts its result to upper case fieldConfig.resolve = async function (source, args, context, info) { const result = await resolve(source, args, context, info); if (typeof result === 'string') { return result.toUpperCase(); } return result; }; return fieldConfig; } }, }); } ~~~ 要將此指令實現應用于包含`@upper`指令的模式,請使用`transformSchema`函數: ~~~typescript GraphQLModule.forRoot<ApolloDriverConfig>({ ... transformSchema: schema => upperDirectiveTransformer(schema, 'upper'), }) ~~~ #### 聯合[#](https://docs.nestjs.com/graphql/migration-guide#federation) `GraphQLFederationModule` 已被移除并替換為相應的驅動程序類: ~~~typescript // Before GraphQLFederationModule.forRoot({ autoSchemaFile: true, }); // After GraphQLModule.forRoot<ApolloFederationDriverConfig>({ driver: ApolloFederationDriver, autoSchemaFile: true, }); ~~~ > **提示**`ApolloFederationDriver`類和`ApolloFederationDriverConfig`都是從`@nestjs/apollo`包中導出的。 同樣,不要使用專用的`GraphQLGatewayModule`,只需將適當的`driver`類傳遞給您的`GraphQLModule`設置: ~~~typescript // Before GraphQLGatewayModule.forRoot({ gateway: { supergraphSdl: new IntrospectAndCompose({ subgraphs: [ { name: 'users', url: 'http://localhost:3000/graphql' }, { name: 'posts', url: 'http://localhost:3001/graphql' }, ], }), }, }); // After GraphQLModule.forRoot<ApolloGatewayDriverConfig>({ driver: ApolloGatewayDriver, gateway: { supergraphSdl: new IntrospectAndCompose({ subgraphs: [ { name: 'users', url: 'http://localhost:3000/graphql' }, { name: 'posts', url: 'http://localhost:3001/graphql' }, ], }), }, }); ~~~ > **提示**`ApolloGatewayDriver`類和`ApolloGatewayDriverConfig`都是從`@nestjs/apollo`包中導出的。
                  <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>

                              哎呀哎呀视频在线观看