Skip to content

Commit

Permalink
feat(apollo-config): allow user to pass config to apollo
Browse files Browse the repository at this point in the history
  • Loading branch information
bikov committed Jun 27, 2019
1 parent ca9adad commit 36cd3de
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
41 changes: 30 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/dal/entities/repository-entity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as joi from 'joi';

export interface RepositoryEntity {
_id: object;
deleted: boolean;
Expand All @@ -13,7 +14,8 @@ export interface RepositoryEntity {
}

const schema = joi.object().keys({
_id: joi.object().required(),
// By default mongoose return _id as object(Mongoose.Types.ObjectId) but if you populate that object its just a string
_id: joi.alternatives([joi.object(), joi.string()]).required(),
deleted: joi.boolean().required(),
createdBy: joi.string(),
lastUpdatedBy: joi.string(),
Expand Down
1 change: 1 addition & 0 deletions src/inversion-of-control/polaris-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ export const POLARIS_TYPES = {
CommonEntityInterface: Symbol('CommonEntityInterface`'),
RealitiesHolder: Symbol('RealitiesHolder'),
RealitiesHolderValidator: Symbol('RealitiesHolderValidator'),
ApolloConfig: Symbol('ApolloConfig'),
};
2 changes: 2 additions & 0 deletions src/server/graphql-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class PolarisGraphQLServer implements GraphQLServer {
private realitiesHolderValidator: RealitiesHolderValidator,
@inject(POLARIS_TYPES.SoftDeleteConfiguration)
private softDeleteConfiguration?: SoftDeleteConfiguration,
@inject(POLARIS_TYPES.ApolloConfig) private userApolloConfig: Config = {},
) {
const executableSchemaWithMiddleware = applyMiddleware(
schema,
Expand All @@ -62,6 +63,7 @@ export class PolarisGraphQLServer implements GraphQLServer {
() => new IrrelevantEntitiesExtension(),
() => new ResponseHeadersExtension(),
],
...userApolloConfig,
};
this.server = new ApolloServer(config);
this.app = new Koa();
Expand Down

0 comments on commit 36cd3de

Please sign in to comment.