diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/package.json b/package.json index 9aa5008..919a1a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "apollo-link-printer", - "version": "1.0.1", + "version": "1.0.2", "description": "Pretty logger of Apollo GraphQL network operations packaged in a Apollo link", "type": "module", "scripts": { diff --git a/src/index.ts b/src/index.ts index 71e6632..c54f163 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1 +1 @@ -export { PrinterLink } from './printerLink'; +export { PrinterLink } from './printerLink.js'; diff --git a/src/printerLink.ts b/src/printerLink.ts index e9a963a..5efc4fe 100644 --- a/src/printerLink.ts +++ b/src/printerLink.ts @@ -1,6 +1,6 @@ import { ApolloLink, NextLink, Operation } from '@apollo/client'; -import { fragmentRow, messageRow, operationRow, variablesRow } from './rows'; -import { TLinkOptions } from './printerLink.types'; +import { fragmentRow, messageRow, operationRow, variablesRow } from './rows/index.js'; +import { TLinkOptions } from './printerLink.types.js'; const prepareSubrows = (operation: Operation) => { const result = { diff --git a/src/rows/index.ts b/src/rows/index.ts index 33bc704..2186726 100644 --- a/src/rows/index.ts +++ b/src/rows/index.ts @@ -67,8 +67,9 @@ export const fragmentRow = ({ query: { definitions } }: Operation) => { * @param {Operation} operation */ // eslint-disable-next-line @typescript-eslint/no-explicit-any -export const operationRow = ({ query: { definitions }, operationName }: Operation | any) => { - const [{ operation: operationType }] = definitions; +export const operationRow = ({ query: { definitions = [] }, operationName }: Operation | any) => { + const definition = definitions.find(({ kind }) => kind === 'OperationDefinition'); + const operationType = definition.operation || 'unknown' return [ `%c ${operationType.toUpperCase()} %c ${operationName}`,