Skip to content

Commit

Permalink
fix(op-reg): Switch to apollo-server-types Logger type.
Browse files Browse the repository at this point in the history
  • Loading branch information
abernix committed Jun 27, 2020
1 parent a6fc182 commit f3fbe15
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import Agent, { AgentOptions } from "../agent";
import { Operation } from "../ApolloServerPluginOperationRegistry";
import { fakeTestBaseUrl, getLegacyOperationManifestUrl, getStoreKey, getOperationManifestUrl, urlOperationManifestBase } from "../common";
import { Logger } from "apollo-server-types";

// These get a bit verbose within the tests below, so we use this as a
// sample store to pick and grab from.
Expand Down Expand Up @@ -147,7 +148,7 @@ describe('Agent', () => {
sampleManifestRecords.c,
]);
const relevantLogs: any = [];
const logger = {
const logger: Logger = {
debug: jest.fn().mockImplementation((...args: any[]) => {
if (
typeof args[0] === 'string' &&
Expand All @@ -166,6 +167,8 @@ describe('Agent', () => {
relevantLogs.push(args);
}
}),
info: () => {},
error: () => {},
};
await createAgent({ logger }).start();

Expand Down Expand Up @@ -198,8 +201,6 @@ describe('Agent', () => {
);

expect(relevantLogs.length).toBe(5);

logger.debug.mockRestore();
});

it('populates the manifest store after starting', async () => {
Expand Down
5 changes: 3 additions & 2 deletions packages/apollo-server-plugin-operation-registry/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ import { Response } from 'node-fetch';
import { InMemoryLRUCache } from 'apollo-server-caching';
import { fetchIfNoneMatch } from './fetchIfNoneMatch';
import { OperationManifest } from "./ApolloServerPluginOperationRegistry";
import { Logger } from "apollo-server-types";

const DEFAULT_POLL_SECONDS: number = 30;
const SYNC_WARN_TIME_SECONDS: number = 60;

export interface AgentOptions {
logger?: loglevel.Logger;
logger?: Logger;
pollSeconds?: number;
schemaHash: string;
engine: any;
Expand All @@ -32,7 +33,7 @@ const callToAction = `Ensure this server's schema has been published with 'apoll

export default class Agent {
private timer?: NodeJS.Timer;
private logger: loglevel.Logger;
private logger: Logger;
private hashedServiceId?: string;
private requestInFlight: Promise<any> | null = null;
private lastSuccessfulCheck?: Date;
Expand Down

0 comments on commit f3fbe15

Please sign in to comment.