name | description | url | github | npm |
---|---|---|---|---|
Apollo Server |
A GraphQL server from Apollo that works with any Node.js HTTP framework |
apollographql/apollo-server |
@apollo/server |
To run a hello world server with Apollo Server:
npm install @apollo/server graphql
Then run node server.js
with this code in server.js
:
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",
},
}
const server = new ApolloServer({
typeDefs,
resolvers,
})
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 via community integrations.
Apollo Server has a plugin API, integration with Apollo Studio, and performance and security features such as caching, automatic persisted queries, and CSRF prevention.