How to use the @apollo/federation.printSchema function in @apollo/federation

To help you get started, we’ve selected a few @apollo/federation examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github juicycleff / ultimate-backend / libs / nestjs-graphql-gateway / src / nestjs-graphql-distributed.module.ts View on Github external
} = this.options;
    const app = httpAdapter.getInstance();

    // @ts-ignore
    const typeDefs = await this.graphqlTypesLoader.getTypesFromPaths(typePaths);

    const mergedTypeDefs = extend(typeDefs, this.options.typeDefs);
    const apolloOptions = await this.graphqlDistributedFactory.mergeOptions({
      ...this.options,
      typeDefs: mergedTypeDefs,
    });

    if (this.options.definitions && this.options.definitions.path) {
      await this.graphqlFactory.generateDefinitions(
        // @ts-ignore
        printSchema(apolloOptions.schema),
        this.options,
      );
    }

    this.apolloServer = new ApolloServer(apolloOptions as any);
    this.apolloServer.applyMiddleware({
      app,
      path,
      disableHealthCheck,
      onHealthCheck,
      cors,
      bodyParserConfig,
    });

    if (this.options.installSubscriptionHandlers) {
      // TL;DR 
github apollo-model / apollo-model / packages / core / src / index.js View on Github external
if (!typeWrap.isAbstract()) {
          Object.values(type.getFields()).map(field => {
            if (getDirective(field, 'unique')) {
              type.astNode.directives.push(
                this.generateKeyDirective(field.name)
              );
            }
          });
          if (!typeWrap.isInterface()) {
            keyTypes.push(type);
          }
        }
      }
    });

    const sdl = printSchema(schema);

    const _Service = new GraphQLObjectType({
      name: '_Service',
      fields: {
        sdl: {
          name: 'sdl',
          type: GraphQLString,
        },
      },
    });
    this.SchemaTypes._Service = _Service;
    this.Query._fields._service = {
      name: '_service',
      args: [],
      isDeprecated: false,
      type: _Service,