Babel-node not lncluding .graphql files in build

Viewed 87

I'm loading .graphql files like this:

import { join } from 'path'
import { loadSchemaSync } from '@graphql-tools/load'
import { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader'
import { addResolversToSchema } from '@graphql-tools/schema'
import resolvers from './resolvers'
const schema = loadSchemaSync(join(__dirname, './typedefs/*.graphql'), { loaders: [new GraphQLFileLoader()] })

const schemaWithResolver = addResolversToSchema({
  schema,
  resolvers
})
export default schemaWithResolver

When I build for production, the folder ./typedefs is not included in the build output (dist).

This is the build cmd: "build-babel": "babel ./src -s -d dist"

How do include .graphql extensions in the babel cmd above?

1 Answers

You can add the --copy-files flag to include non-js files.

Changing the build command to this should work:

"build-babel": "babel ./src -s -d dist --copy-files"
Related