Skip to content

Commit

Permalink
style: formatting with prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxmachine authored and Rick Dutour Geerling committed Jan 20, 2020
1 parent 5940608 commit 3a54832
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 36 deletions.
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"printWidth": 100,
"trailingComma": "all",
"singleQuote": true
}
2 changes: 1 addition & 1 deletion lib/decorators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export * from './mutation.decorator';
export * from './parent.decorator';
export * from './query.decorator';
export * from './resolve-property.decorator';
export * from './resolve-reference.decorator';
export * from './resolver.decorator';
export * from './root.decorator';
export * from './scalar.decorator';
export * from './subscription.decorator';
export * from './resolve-reference.decorator';
12 changes: 9 additions & 3 deletions lib/graphql-federation.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { gql } from 'apollo-server-core';
import { loadPackage } from '@nestjs/common/utils/load-package.util';

import { extend } from './utils';
import { ScalarsExplorerService, DelegatesExplorerService, ResolversExplorerService } from './services';
import {
ScalarsExplorerService,
DelegatesExplorerService,
ResolversExplorerService,
} from './services';
import { GqlModuleOptions } from './interfaces';

@Injectable()
Expand All @@ -29,9 +33,11 @@ export class GraphQLFederationFactory {

const schema = buildFederatedSchema([
{
typeDefs: gql`${options.typeDefs}`,
typeDefs: gql`
${options.typeDefs}
`,
resolvers,
}
},
]);

return {
Expand Down
21 changes: 11 additions & 10 deletions lib/graphql-federation.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { loadPackage } from '@nestjs/common/utils/load-package.util';
import { HttpAdapterHost } from '@nestjs/core';

import { GraphQLFederationFactory } from './graphql-federation.factory';
import { ScalarsExplorerService, DelegatesExplorerService, ResolversExplorerService } from './services';
import {
ScalarsExplorerService,
DelegatesExplorerService,
ResolversExplorerService,
} from './services';
import { GraphQLAstExplorer } from './graphql-ast.explorer';
import { GraphQLTypesLoader } from './graphql-types.loader';
import { GraphQLSchemaBuilder } from './graphql-schema-builder';
Expand Down Expand Up @@ -69,9 +73,7 @@ export class GraphQLFederationModule implements OnModuleInit {
};
}

private static createAsyncProviders(
options: GqlModuleAsyncOptions,
): Provider[] {
private static createAsyncProviders(options: GqlModuleAsyncOptions): Provider[] {
if (options.useExisting || options.useFactory) {
return [this.createAsyncOptionsProvider(options)];
}
Expand All @@ -85,9 +87,7 @@ export class GraphQLFederationModule implements OnModuleInit {
];
}

private static createAsyncOptionsProvider(
options: GqlModuleAsyncOptions,
): Provider {
private static createAsyncOptionsProvider(options: GqlModuleAsyncOptions): Provider {
if (options.useFactory) {
return {
provide: GRAPHQL_MODULE_OPTIONS,
Expand All @@ -104,10 +104,11 @@ export class GraphQLFederationModule implements OnModuleInit {
}

async onModuleInit() {
if (!this.httpAdapterHost) return;
const { httpAdapter } = this.httpAdapterHost;
const { httpAdapter } = this.httpAdapterHost || {};

if (!httpAdapter) return;
if (!httpAdapter) {
return;
}

const { printSchema } = loadPackage('@apollo/federation', 'ApolloFederation');

Expand Down
10 changes: 6 additions & 4 deletions lib/graphql-gateway.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export class GraphQLGatewayModule implements OnModuleInit {
constructor(
@Optional()
private readonly httpAdapterHost: HttpAdapterHost,
@Optional() @Inject(GRAPHQL_GATEWAY_BUILD_SERVICE)
@Optional()
@Inject(GRAPHQL_GATEWAY_BUILD_SERVICE)
private readonly buildService: GatewayBuildService,
@Inject(GRAPHQL_GATEWAY_MODULE_OPTIONS)
private readonly options: GatewayModuleOptions,
Expand All @@ -31,10 +32,11 @@ export class GraphQLGatewayModule implements OnModuleInit {
}

async onModuleInit() {
if (!this.httpAdapterHost) return;
const { httpAdapter } = this.httpAdapterHost;
const { httpAdapter } = this.httpAdapterHost || {};

if (!httpAdapter) return;
if (!httpAdapter) {
return;
}

const { ApolloGateway } = loadPackage('@apollo/gateway', 'ApolloGateway');
const app = httpAdapter.getInstance();
Expand Down
4 changes: 2 additions & 2 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ export * from './graphql-ast.explorer';
export * from './graphql-definitions.factory';
export * from './graphql-types.loader';
export * from './graphql.factory';
export * from './graphql-federation.module';
export * from './graphql-gateway.module';
export * from './graphql.module';
export * from './interfaces';
export * from './services/gql-arguments-host';
export * from './services/gql-execution-context';
export * from './tokens';
export * from './graphql-federation.module';
export * from './graphql-gateway.module';
20 changes: 4 additions & 16 deletions lib/utils/extract-metadata.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,18 @@ export function extractMetadata(
Reflect.getMetadata(RESOLVER_TYPE_METADATA, callback) ||
Reflect.getMetadata(RESOLVER_TYPE_METADATA, instance.constructor);

const isPropertyResolver = !!Reflect.getMetadata(
RESOLVER_PROPERTY_METADATA,
callback,
);
const isPropertyResolver = !!Reflect.getMetadata(RESOLVER_PROPERTY_METADATA, callback);

const resolverName = Reflect.getMetadata(RESOLVER_NAME_METADATA, callback);
const isDelegated = !!Reflect.getMetadata(
RESOLVER_DELEGATE_METADATA,
callback,
);

const isReferenceResolver = !!Reflect.getMetadata(
RESOLVER_REFERENCE_METADATA,
callback,
);
const isDelegated = !!Reflect.getMetadata(RESOLVER_DELEGATE_METADATA, callback);

const isReferenceResolver = !!Reflect.getMetadata(RESOLVER_REFERENCE_METADATA, callback);

if (filterPredicate(resolverType, isDelegated, isReferenceResolver, isPropertyResolver)) {
return null;
}

const name = isReferenceResolver
? RESOLVER_REFERENCE_KEY
: resolverName || methodName;
const name = isReferenceResolver ? RESOLVER_REFERENCE_KEY : resolverName || methodName;

return {
type: resolverType,
Expand Down

0 comments on commit 3a54832

Please sign in to comment.