Skip to content

How to modularize schema #4777

Answered by KeithGillette
ssmilin asked this question in Q&A
Discussion options

You must be logged in to vote

I built a simple service class to accomplish this in our Apollo Server project, but the logic of getSchemas should be all you need, since it's actually stateless.

import { gql } from 'apollo-angular';
import { readdirSync, readFileSync, statSync } from 'fs';
import { join } from 'path';
import { DocumentNode } from 'graphql';

import { Service } from '../infrastructure/decorators/service.decorator';


const schemaFolder = 'assets/app/core/application/schema';

/** Injectable() service providing GraphQL schema array */
@Service()
export class SchemaService {
	public getSchemas(): DocumentNode[] {
		function buildFilePathList(directoryPath: string): string[] {
			const directoryEntryList = r…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ssmilin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants