Comments (10)
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.
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.
@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 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.
@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.
@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.
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.
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.
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)
- Counting type complexity only once HOT 4
- Empty runtime variables with @include directive HOT 2
- Feature Request: Support adding cost on types HOT 2
- API stability? HOT 2
- ApolloServer and Upload File HOT 2
- how to calculate connection fields HOT 1
- `TypeError` from passing invalid arguments when there's more than one query present HOT 9
- Support Node.js ESM HOT 2
- Support grqphql.js version 16 HOT 1
- Weird error when running mutations with invalid inputs HOT 6
- Using this in an Apollo Gateway without `schema` HOT 2
- Feature Request: Complexity estimator receives all args to be used as multiplier factor HOT 4
- Feature request: Federation support for directives HOT 3
- Is there a way to assign complexities to mutations, objects and fields by default ? HOT 1
- Support passing context to estimators
- How to implement with Apollo server v3
- Feature request: adding path to estimators args(for calculating actual query complexity)
- GQL causes TypeError: "Cannot read properties of undefined (reading 'name')" HOT 2
- Feature request: Add directive estimation support for "initial complexity"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-query-complexity.