/** * Exports a PostGraphile schema by looking at a Postgres client. */ export default async function exportPostGraphileSchema( schema: GraphQLSchema, options: PostGraphileOptions = {}, ): Promise<void> { const jsonPath = typeof options.exportJsonSchemaPath === 'string' ? options.exportJsonSchemaPath : null; const graphqlPath = typeof options.exportGqlSchemaPath === 'string' ? options.exportGqlSchemaPath : null; // Sort schema, if requested const finalSchema = options.sortExport && lexicographicSortSchema && (jsonPath || graphqlPath) ? lexicographicSortSchema(schema) : schema; // JSON version if (jsonPath) { const result = await graphql(finalSchema, introspectionQuery); await writeFileIfDiffers(jsonPath, JSON.stringify(result, null, 2)); } // Schema language version if (graphqlPath) { await writeFileIfDiffers(graphqlPath, printSchema(finalSchema)); } }
export default function printSchemaOrdered(originalSchema) { const schema = buildASTSchema(parse(printSchema(originalSchema))); return printSchema(schema);
Bootstrap(FederationModule.forRoot(config)).subscribe( () => { Container.get(ApolloGatewayInternal).onSchemaChange((schema) => console.log(` ${process.env.GATEWAY_PRINT_SCHEMA ? `Schema: ${printSchema(schema)}` : ''} Loaded remote graphs: ${config.serviceList.map((s) => `\n1. ${s.name} - ${s.url}`)} `), ); }, (e) => console.log(e), );
promise.then(schema => process.stdout.write(printSchema(schema)));
@Type( new GraphQLObjectType({ name: 'GraphqlFederation', fields: () => ({ sdl: { type: GraphQLString } }), }) ) @Query() _service() { const appSchema = Container.get( GRAPHQL_PLUGIN_CONFIG ) as GRAPHQL_PLUGIN_CONFIG; return { sdl: printSchema( new GraphQLSchema({ query: appSchema.graphqlOptions.schema.getQueryType(), mutation: appSchema.graphqlOptions.schema.getMutationType(), }) ), }; }
Bootstrap(FederationModule.forRoot(config)).subscribe( () => { Container.get(ApolloGatewayInternal).onSchemaChange((schema) => console.log(` ${process.env.GATEWAY_PRINT_SCHEMA ? `Schema: ${printSchema(schema)}` : ''} Loaded remote graphs: ${config.serviceList.map((s) => `\n1. ${s.name} - ${s.url}`)} `), ); }, (e) => console.log(e), );
@Type( new GraphQLObjectType({ name: 'GraphqlFederation', fields: () => ({ sdl: { type: GraphQLString } }), }) ) @Query() _service() { const appSchema = Container.get( GRAPHQL_PLUGIN_CONFIG ) as GRAPHQL_PLUGIN_CONFIG; return { sdl: printSchema( new GraphQLSchema({ query: appSchema.graphqlOptions.schema.getQueryType(), mutation: appSchema.graphqlOptions.schema.getMutationType(), }) ), }; }