the-road-to-graphql / fullstack-apollo-express-postgresql-boilerplate

💥 A sophisticated GraphQL with Apollo, Express and PostgreSQL boilerplate project.
https://roadtoreact.com
MIT License
1.2k stars 265 forks source link

gql error when using imports #124

Closed petelc closed 3 years ago

petelc commented 3 years ago

SO I am just starting on the final section of the book. So I am getting some weird errors when i use imports ..... So here is my imports:

import cors from 'cors'; import { ApolloServer, gql } from 'apollo-server-express'; import express from 'express';

first I got a cant use imports outside a module so i put in "type": "module" in the package.json which solved that error but now i get this error:

import { ApolloServer, gql } from 'apollo-server-express'; ^^^ SyntaxError: The requested module 'apollo-server-express' does not provide an export named 'gql' at ModuleJob._instantiate (internal/modules/esm/module_job.js:92:21) at async ModuleJob.run (internal/modules/esm/module_job.js:107:20) at async Loader.import (internal/modules/esm/loader.js:179:24) [nodemon] app crashed - waiting for file changes before starting...

So the strange thing is that it works when i take out the type/module and switch the imports to requires. And I fully realize that this is probably something super simple that I should be seeing.

Thanks for any help