diff --git a/docs/source/integrations/mern.mdx b/docs/source/integrations/mern.mdx index b0a3969e177..b9f1e084709 100644 --- a/docs/source/integrations/mern.mdx +++ b/docs/source/integrations/mern.mdx @@ -61,10 +61,10 @@ This schema lets you perform various actions on records: fetching single or mult Resolver functions are responsible for performing the actions defined in the schema—for example, fetching and updating records. In a MERN stack application, they're how you connect the GraphQL schema to your MongoDB instance. -In your server's `/src` folder, create a new `resolvers.ts` file and paste in the following resolvers: +In your server's `/src` folder, create a new `resolvers.js` file and paste in the following resolvers: -```ts -import db from "./db/conn.ts"; +```js +import db from "./db/connection.js"; const resolvers = { Record: { @@ -122,19 +122,19 @@ To learn more about writing resolver functions, check out the [resolver docs](.. ## Step 4: Add Apollo Server to your Express server -Now you can begin integrating Apollo Server into your Express server. Wherever you instantiate your `express` server (usually `mern/server/server.ts`), import `@apollo/server` and its `expressMiddleware`. Then, instantiate and `start` the Apollo Server: +Now you can begin integrating Apollo Server into your Express server. Wherever you instantiate your `express` server (usually `mern/server/server.js`), import `@apollo/server` and its `expressMiddleware`. Then, instantiate and `start` the Apollo Server: -```ts -import express, { json } from 'express'; +```js +import express from 'express'; import cors from 'cors'; -import "./loadEnvironment.mjs"; -import records from "./routes/record.mjs"; +import records from "./routes/record.js"; + //highlight-start import gql from "graphql-tag"; import { ApolloServer } from '@apollo/server'; import { buildSubgraphSchema } from '@apollo/subgraph'; import { expressMiddleware } from '@apollo/server/express4'; -import resolvers from "./resolvers.mjs"; +import resolvers from "./resolvers.js"; import { readFileSync } from "fs"; //highlight-end @@ -180,7 +180,7 @@ app.use("/record", records); app.use( '/graphql', cors(), - json(), + express.json(), expressMiddleware(server), ); //highlight-end @@ -251,4 +251,4 @@ Congrats on completing the tutorial! 🎉 Incorporating a GraphQL server into yo While this tutorial only covers the server portion of the MERN stack, the `/client` folder in the [completed example](#complete-example) picks up where the tutorial left off and implements [`@apollo/client`](/react/) to interact with the server. For more information on implementing the Apollo Client, head to the [getting started docs](/react/get-started). -For more hands-on learning on GraphQL and Apollo's server and client libraries, check out our interactive [Odyssey tutorials](https://www.apollographql.com/tutorials/). \ No newline at end of file +For more hands-on learning on GraphQL and Apollo's server and client libraries, check out our interactive [Odyssey tutorials](https://www.apollographql.com/tutorials/).