esm.sh
esm.sh copied to clipboard
Failed to import graphql - library seems to be completely broken
Failing module
- GitHub:
- npm: graphql
import { GraphQLError } from 'https://esm.sh/[email protected]/graphql'
Error message
After running deno run
I got this:
error: Uncaught SyntaxError: The requested module '/v111/[email protected]/deno/graphql.js' does not provide an export named 'GraphQLError'
Additional info
- esm.sh version: No idea.
- Deno version: deno 1.31.2 (release, aarch64-apple-darwin) v8 11.0.226.19 typescript 4.9.4
Module used to work until about 8th of March 2023. After that Deno actually complained about hash change and after reloading everything error started to appear.
Hi @jtiai , Seems the https://unpkg.com/[email protected]/graphql.js file has not exported the GraphQLError
module.
In your case, you should use to instead.
import { GraphQLError } from 'https://esm.sh/[email protected]/index'
hope can help you. : )
Hi @jtiai , Seems the https://unpkg.com/[email protected]/graphql.js file has not exported the
GraphQLError
module. In your case, you should use to instead.import { GraphQLError } from 'https://esm.sh/[email protected]/index'
hope can help you. : )
The catch is that plain graphql import is being widely used by many 3rd party packages which I can't change.
The catch is that plain graphql import is being widely used by many 3rd party packages which I can't change.
Okay, I found the problem that is due to an import file conflict, fixing it.
@jtiai We has been fixed the entry point bug, could you please try again?
The pin v112
will resolve the import path to
https://esm.sh/[email protected]
to https://esm.sh/v112/[email protected]/es2022/graphql.mjs
and export some correct modules.
After doing some work with imports I hit an another error:
error: Uncaught ReferenceError: process is not defined
process.env.NODE_ENV === 'production'
^
at https://esm.sh/[email protected]/jsutils/instanceOf.mjs:13:3
And that module is imported from quite many places.
@jtiai Could you please share your full use case?
This is MVP which triggers the error:
import { GraphQLScalarType, ValueNode } from "https://esm.sh/[email protected]/type/index.mjs";
import { Kind } from "https://esm.sh/[email protected]/language/kinds.mjs";
const dateTimeScalar = new GraphQLScalarType({
name: "DateTime",
description: "Date and time scalar type",
serialize(value: unknown): string {
return (value as string); // REST API sends timestamps as ISO strings already
},
parseValue(value: unknown): Date {
return new Date(value as string); // Convert ISO date string to Date
},
parseLiteral(ast: ValueNode): Date | null {
if (ast.kind === Kind.STRING) {
return new Date(ast.value); // Do not change incoming string
}
return null; // Something fishy
},
});
@jtiai please remove .mjs
extension of your imports, we will fix this later
import { GraphQLScalarType, ValueNode } from "https://esm.sh/[email protected]/type/index";
import { Kind } from "https://esm.sh/[email protected]/language/kinds";
I guess that worked but now I get schema errors. For some reasons this is only thing that so far works:
import { GraphQLScalarType, Kind, ValueNode } from "npm:graphql@^16.6.0";
This happens on v130 when importing different parts of graphql:
error: Error: Cannot use GraphQLSchema "{ __validationErrors: undefined, description: undefined, extensions: {}, astNode: undefined, extensionASTNodes: [], _queryType: Query, _mutationType: undefined, _subscriptionType: undefined, _directives: [@include, @skip, @deprecated, @specifiedBy], _typeMap: { Query: Query, String: String, Boolean: Boolean, __Schema: __Schema, __Type: __Type, __TypeKind: __TypeKind, __Field: __Field, __InputValue: __InputValue, __EnumValue: __EnumValue, __Directive: __Directive, __DirectiveLocation: __DirectiveLocation }, _subTypeMap: {}, _implementationsMap: {} }" from another module or realm.
Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.
https://yarnpkg.com/en/docs/selective-version-resolutions
Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.
at Y (https://esm.sh/v130/[email protected]/denonext/graphql.js:12:2032)
at ji (https://esm.sh/v130/[email protected]/denonext/graphql.js:52:8341)
at rr (https://esm.sh/v130/[email protected]/denonext/graphql.js:52:8368)
at tn (https://esm.sh/v130/[email protected]/denonext/graphql.js:52:11885)
at si (https://esm.sh/v130/[email protected]/denonext/graphql.js:54:50300)
at https://esm.sh/v130/[email protected]/denonext/graphql.js:54:49916
at new Promise (<anonymous>)
at hd (https://esm.sh/v130/[email protected]/denonext/graphql.js:54:49899)
at runHttpQuery (file:///home/v1rtl/Coding/gql/common.ts:28:16)
at ItNode.fn (file:///home/v1rtl/Coding/gql/mod_test.ts:277:26)