graphql-tools icon indicating copy to clipboard operation
graphql-tools copied to clipboard

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

Open venkateshpullaganti opened this issue 3 years ago • 2 comments

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 :smile:

venkateshpullaganti avatar Feb 24 '22 11:02 venkateshpullaganti

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

ardatan avatar Feb 24 '22 12:02 ardatan

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.

venkateshpullaganti avatar Feb 24 '22 14:02 venkateshpullaganti