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

Can't import the named export XXXX from non EcmaScript module (only default export is available) #4265

Open
Tracked by #5201 ...
venkateshpullaganti opened this issue Feb 24, 2022 · 2 comments

Comments

@venkateshpullaganti
Copy link

venkateshpullaganti commented Feb 24, 2022

Describe the bug
Can't import the named export XXXX from non EcmaScript module (only default export is available)(https://stackoverflow.com/questions/69343038/cant-import-the-named-export-xxxx-from-non-ecmascript-module-only-default-expo)

Expected behaviour
Run without errors

Environment:

  • OS: Ubuntu 20.04
  • @graphql-tools/: "8.2.0"
  • "@graphql-tools/mock": "8.5.1",
  • NodeJS:c14.17.0
  • Craco: 6.4.3
  • react-scripts: "4.0.3",
  • React : 17.0.2

My Code

import { makeExecutableSchema } from '@graphql-tools/schema'
import { loadSchemaSync } from '@graphql-tools/load'
import { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader'
import casual from 'casual'

const typeDefs = loadSchemaSync('./schema.graphql', {
   loaders: [new GraphQLFileLoader()]
})


const schemaWithMocks = makeExecutableSchema({
   typeDefs
})

export default schemaWithMocks

The Error I got is

Failed to compile.

./node_modules/@graphql-tools/load/index.mjs
Can't import the named export 'AggregateError' from non EcmaScript module (only default export is available)

Additional context
I got it worked as by following this solution.
Can Anyone provide a proper fix to this?
TIA 😄

@ardatan
Copy link
Owner

ardatan commented Feb 24, 2022

I think This seems an issue with the bundler with .mjs extensions.

@venkateshpullaganti
Copy link
Author

I think This seems an issue with the bundler with .mjs extensions.
hi @ardatan, Tq for the quick response. I really appreciate it.
Can you point me to where can I find the solution? It would really help me.

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

No branches or pull requests

2 participants