GithubHelp home page GithubHelp logo

Comments (5)

kamilkowalski avatar kamilkowalski commented on July 20, 2024

Ok, I found the issue - the logger option is documented1 as:

Logger instance that matches Console interface of NodeJS

But in fact the resolveLogger function only uses that option if it's a string designating a module to be loaded.2

That's a bit confusing. Is the problem that of build vs runtime - so we can't really pass an instance because the config is only used to generate TypeScript artifacts so they need to contain the code that instantiated the logger?

I managed to work around it by passing a path to a TypeScript module in the logger option:

{
  logger: "./logger"
}

And doing the setup in that file. If it's impossible to pass an instance of the logger in config then I can update the type documentation, but I'd appreciate someone confirming this.

Footnotes

  1. https://github.com/ardatan/graphql-mesh/blob/89c1abb9504bf785b3d11c23d2717a86806a428a/packages/legacy/types/src/config.ts#L56

  2. https://github.com/ardatan/graphql-mesh/blob/89c1abb9504bf785b3d11c23d2717a86806a428a/packages/legacy/config/src/utils.ts#L276

from graphql-mesh.

kamilkowalski avatar kamilkowalski commented on July 20, 2024

Just noticed the above doesn't work for production builds because the import isn't handled correctly - Mesh tries to load the file from the .mesh directory instead of going up one directory similarly to how it handles additional resolvers.

from graphql-mesh.

ardatan avatar ardatan commented on July 20, 2024

Actually that option is not supposed to an object as a logger. But a path to a code file that exports an object implements Logger from @graphql-mesh/types.
It is a missing documentation in that case.
But after build, if it doesn't load the module from the path correctly. This is a bug then.
Thanks for the feedback!
Apparently the types there and resolveLogger need to be fixed.
Would you try to tackle it in a PR?

from graphql-mesh.

kamilkowalski avatar kamilkowalski commented on July 20, 2024

I'll take a stab at it. 😊

from graphql-mesh.

ardatan avatar ardatan commented on July 20, 2024

Thanks <3 ! Let us know if you need any questions and support!

from graphql-mesh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.