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

Failed to import graphql - library seems to be completely broken #547

Open
jtiai opened this issue Mar 15, 2023 · 10 comments
Open

Failed to import graphql - library seems to be completely broken #547

jtiai opened this issue Mar 15, 2023 · 10 comments
Labels
deno Not working in Deno

Comments

@jtiai
Copy link

jtiai commented Mar 15, 2023

Failing module

  • GitHub:
  • npm: graphql
import { GraphQLError } from 'https://esm.sh/graphql@16.6.0/graphql'

Error message

After running deno run I got this:

error: Uncaught SyntaxError: The requested module '/v111/graphql@16.6.0/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.

@jtiai jtiai added the deno Not working in Deno label Mar 15, 2023
@jtiai jtiai changed the title Failed to import - Failed to import graphql - library seems to be completely broken Mar 15, 2023
@Justinidlerz
Copy link
Contributor

Hi @jtiai , Seems the https://unpkg.com/graphql@16.6.0/graphql.js file has not exported the GraphQLError module.
In your case, you should use to instead.

import { GraphQLError } from 'https://esm.sh/graphql@16.6.0/index'

hope can help you. : )

@jtiai
Copy link
Author

jtiai commented Mar 16, 2023

Hi @jtiai , Seems the https://unpkg.com/graphql@16.6.0/graphql.js file has not exported the GraphQLError module. In your case, you should use to instead.

import { GraphQLError } from 'https://esm.sh/graphql@16.6.0/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.

@Justinidlerz
Copy link
Contributor

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.

@Justinidlerz
Copy link
Contributor

@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/graphql@16.6.0 to https://esm.sh/v112/graphql@16.6.0/es2022/graphql.mjs and export some correct modules.
image

@jtiai
Copy link
Author

jtiai commented Mar 27, 2023

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/graphql@16.6.0/jsutils/instanceOf.mjs:13:3

And that module is imported from quite many places.

@Justinidlerz
Copy link
Contributor

@jtiai Could you please share your full use case?

@jtiai
Copy link
Author

jtiai commented Mar 27, 2023

This is MVP which triggers the error:

import { GraphQLScalarType, ValueNode } from "https://esm.sh/graphql@16.6.0/type/index.mjs";
import { Kind } from "https://esm.sh/graphql@16.6.0/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
  },
});

@ije
Copy link
Member

ije commented Mar 28, 2023

@jtiai please remove .mjs extension of your imports, we will fix this later

import { GraphQLScalarType, ValueNode } from "https://esm.sh/graphql@16.6.0/type/index";
import { Kind } from "https://esm.sh/graphql@16.6.0/language/kinds";

@jtiai
Copy link
Author

jtiai commented Mar 30, 2023

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";

@talentlessguy
Copy link
Contributor

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/graphql@16.7.1/denonext/graphql.js:12:2032)
    at ji (https://esm.sh/v130/graphql@16.7.1/denonext/graphql.js:52:8341)
    at rr (https://esm.sh/v130/graphql@16.7.1/denonext/graphql.js:52:8368)
    at tn (https://esm.sh/v130/graphql@16.7.1/denonext/graphql.js:52:11885)
    at si (https://esm.sh/v130/graphql@16.7.1/denonext/graphql.js:54:50300)
    at https://esm.sh/v130/graphql@16.7.1/denonext/graphql.js:54:49916
    at new Promise (<anonymous>)
    at hd (https://esm.sh/v130/graphql@16.7.1/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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deno Not working in Deno
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants