Giter Club home page Giter Club logo

Comments (10)

andresusanto avatar andresusanto commented on May 10, 2024 2

thanks @ivome, I've confirmed that earlier v14 versions don't have the .mjs, but since 14.6 they all do, so I'll raise PR for this.

from graphql-query-complexity.

andresusanto avatar andresusanto commented on May 10, 2024

I'm also facing the same issue. I'm guessing the problem is affecting all people that have their application built as esm (for example in my case, I'm using esbuild).

But I think it is a requirement for esm to specify the file extensions, so I think that's why it was there in the first place. So, what I ended up doing was creating an additional step after the build to replace graphql/execution/values.js with graphql/execution/values.mjs : master...andresusanto:graphql-query-complexity:master . I've published the fix here https://www.npmjs.com/package/@susanto/graphql-query-complexity in case you're interested @jer-sen

^ @slicknode is this something you would consider merging into your repo?

from graphql-query-complexity.

jer-sen avatar jer-sen commented on May 10, 2024

@andresusanto I don't see any issue to remove the file extensions, it's a serverside module https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

from graphql-query-complexity.

andresusanto avatar andresusanto commented on May 10, 2024

@andresusanto I don't see any issue to remove the file extensions, it's a serverside module https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

I'm not quite sure what you meant by "serverside module", but perhaps check this one out?
https://nodejs.org/api/esm.html#mandatory-file-extensions

from graphql-query-complexity.

jer-sen avatar jer-sen commented on May 10, 2024

@andresusanto you are right. Relative and absolute specifiers must have a file extension (in the build directories) but this does not apply to bare specifiers. So graphql module should be imported without a file extension. Do you agree ?

from graphql-query-complexity.

ivome avatar ivome commented on May 10, 2024

@slicknode is this something you would consider merging into your repo?

@andresusanto it looks like this is a general issue with the ESM version of this library, so it is probably a good idea to fix this here. We just have to make sure we are not breaking things for particular graphql-js library versions. I think the 14.x versions didn't have .mjs exports, but since we dropped support for this it's probably safe to change it here.

from graphql-query-complexity.

martin-cycle avatar martin-cycle commented on May 10, 2024

Any update on this issue ? I am facing the same problem with my graphql scalars. I tried to use your own version of the library @andresusanto but it still raises the same issue: Cannot use GraphQLNonNull \"ID!\" from another module or realm.

I also tried to simply copy paste the code in my codebase while removing the .js extension in the import but I got the same problem.

from graphql-query-complexity.

Avadakedvr avatar Avadakedvr commented on May 10, 2024

Having the same issue.

Error: Cannot use GraphQLScalarType \"String\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results.

Anyone managed to solve this? I have tried the resolutions suggestion, ran yarn list --pattern graphql and made sure there is a single graphql version, still getting the error.

from graphql-query-complexity.

Avadakedvr avatar Avadakedvr commented on May 10, 2024

Can confirm have managed to get rid of the error by removing .js from that import. We have initially manually done this within node_modules folder to test, then have automated that by adding graphql/execution/values.js': 'graphql/execution/values' to the resolve->alias webpack config property (using webpack within this given project)

from graphql-query-complexity.

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.