Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generating logger import code and improve documentation #7118

Merged
merged 6 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/orange-seas-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@graphql-mesh/config': patch
'@graphql-mesh/types': patch
---

`logger` configuration option only accepts a string
9 changes: 7 additions & 2 deletions packages/legacy/config/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,17 +271,22 @@ export async function resolveLogger(
code: string;
logger: Logger;
}> {
if (typeof loggerConfig === 'string') {
if (loggerConfig) {
const { moduleName, resolved: logger } = await getPackage<Logger>({
name: loggerConfig,
type: 'logger',
importFn,
cwd,
additionalPrefixes: additionalPackagePrefixes,
});

const processedModuleName = moduleName.startsWith('.')
? path.join('..', moduleName)
: moduleName;

return {
logger,
importCode: `import logger from ${JSON.stringify(moduleName)};`,
importCode: `import logger from ${JSON.stringify(processedModuleName)};`,
code: '',
};
}
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy/config/yaml-config.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ type Query {
"""
persistedOperations: PersistedOperationsConfig
"""
Logger instance that matches `Console` interface of NodeJS
Path to a file exporting a logger instance compatible with the `Logger` type from `@graphql-mesh/types`
"""
logger: Any
logger: String
"""
Path to a custom W3 Compatible Fetch Implementation
"""
Expand Down
16 changes: 2 additions & 14 deletions packages/legacy/types/src/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4382,20 +4382,8 @@
"description": "Configure persisted operations options"
},
"logger": {
"anyOf": [
{
"type": "object",
"additionalProperties": true
},
{
"type": "string"
},
{
"type": "array",
"additionalItems": true
}
],
"description": "Logger instance that matches `Console` interface of NodeJS"
"type": "string",
"description": "Path to a file exporting a logger instance compatible with the `Logger` type from `@graphql-mesh/types`"
},
"customFetch": {
"anyOf": [
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy/types/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ export interface Config {
documents?: string[];
persistedOperations?: PersistedOperationsConfig;
/**
* Logger instance that matches `Console` interface of NodeJS
* Path to a file exporting a logger instance compatible with the `Logger` type from `@graphql-mesh/types`
*/
logger?: any;
logger?: string;
/**
* Path to a custom W3 Compatible Fetch Implementation
*/
Expand Down