From e732f311283a038df501bf3fe7c13340c72461a1 Mon Sep 17 00:00:00 2001 From: Jeff Auriemma Date: Wed, 19 Feb 2025 07:02:27 -0500 Subject: [PATCH 1/2] Update Apollo Server code snippet Resolves #1078 --- .../javascript/server/apollo-server.md | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/code/language-support/javascript/server/apollo-server.md b/src/code/language-support/javascript/server/apollo-server.md index d88aa3ef09..0676b128ff 100644 --- a/src/code/language-support/javascript/server/apollo-server.md +++ b/src/code/language-support/javascript/server/apollo-server.md @@ -15,30 +15,30 @@ npm install @apollo/server graphql Then run `node server.js` with this code in `server.js`: ```js -import { ApolloServer } from "@apollo/server" -import { startStandaloneServer } from "@apollo/server/standalone" -import { buildSchema } from "graphql" +import { ApolloServer } from '@apollo/server'; +import { startStandaloneServer } from '@apollo/server/standalone'; -const schema = buildSchema(` - type Query { - hello: String - } -`) +// The GraphQL schema +const typeDefs = `#graphql + type Query { + hello: String + } +`; +// A map of functions which return data for the schema. const resolvers = { Query: { - hello: () => "Hello World!", + hello: () => 'world', }, -} +}; const server = new ApolloServer({ typeDefs, resolvers, -}) +}); -const { url } = await startStandaloneServer(server) - -console.log(`🚀 Server ready at ${url}`) +const { url } = await startStandaloneServer(server); +console.log(`🚀 Server ready at ${url}`); ``` Apollo Server has a built in standalone HTTP server and middleware for Express, and has an framework integration API that supports all [Node.js HTTP server frameworks and serverless environments](https://www.apollographql.com/docs/apollo-server/integrations/integration-index) via community integrations. From 8be22d081be3391d41c36500e07727a8b4afc39e Mon Sep 17 00:00:00 2001 From: Jeff Auriemma Date: Fri, 28 Feb 2025 09:31:12 -0500 Subject: [PATCH 2/2] Prettier --- .../javascript/server/apollo-server.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/code/language-support/javascript/server/apollo-server.md b/src/code/language-support/javascript/server/apollo-server.md index 0676b128ff..ac951b7f41 100644 --- a/src/code/language-support/javascript/server/apollo-server.md +++ b/src/code/language-support/javascript/server/apollo-server.md @@ -15,30 +15,30 @@ npm install @apollo/server graphql Then run `node server.js` with this code in `server.js`: ```js -import { ApolloServer } from '@apollo/server'; -import { startStandaloneServer } from '@apollo/server/standalone'; +import { ApolloServer } from "@apollo/server" +import { startStandaloneServer } from "@apollo/server/standalone" // The GraphQL schema const typeDefs = `#graphql type Query { hello: String } -`; +` // A map of functions which return data for the schema. const resolvers = { Query: { - hello: () => 'world', + hello: () => "world", }, -}; +} const server = new ApolloServer({ typeDefs, resolvers, -}); +}) -const { url } = await startStandaloneServer(server); -console.log(`🚀 Server ready at ${url}`); +const { url } = await startStandaloneServer(server) +console.log(`🚀 Server ready at ${url}`) ``` Apollo Server has a built in standalone HTTP server and middleware for Express, and has an framework integration API that supports all [Node.js HTTP server frameworks and serverless environments](https://www.apollographql.com/docs/apollo-server/integrations/integration-index) via community integrations.