3.1.0 • Published 5 years ago

apollo-server-native v3.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Apollo Server integration for native Node.js HTTP

npm version

This integration of Apollo Server works with native Node.js HTTP.

Installation

Install package with yarn or npm:

yarn add apollo-server-native graphql
npm install apollo-server-native graphql

Example with HTTP

const http = require('http')
const { ApolloServer, gql } = require('apollo-server-native')

const typeDefs = gql`
  type Query {
    hello: String
  }
`

const resolvers = {
  Query: {
    hello: () => 'Hello world!',
  },
}

const apolloServer = new ApolloServer({ typeDefs, resolvers })

const server = http.createServer()

server.on('request', apolloServer.createHandler())

server.listen({ port: 3000 }, () =>
  console.log(
    `🚀 Server ready at http://localhost:3000${apolloServer.graphqlPath}`
  )
)

Example with HTTPS

const https = require('https')
const { ApolloServer, gql } = require('apollo-server-native')

const typeDefs = gql`
  type Query {
    hello: String
  }
`

const resolvers = {
  Query: {
    hello: () => 'Hello world!',
  },
}

const apolloServer = new ApolloServer({ typeDefs, resolvers })

const server = https.createServer({
  key: fs.readFileSync('key.pem'),
  cert: fs.readFileSync('cert.pem'),
})

server.on('request', apolloServer.createHandler())

server.listen({ port: 3000 }, () =>
  console.log(
    `🚀 Server ready at https://localhost:3000${apolloServer.graphqlPath}`
  )
)
3.1.0

5 years ago

2.1.0

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.0

6 years ago

1.0.0-beta.7

6 years ago

1.0.0-beta.6

6 years ago

1.0.0-beta.5

6 years ago

1.0.0-beta.4

6 years ago

1.0.0-beta.3

6 years ago

1.0.0-beta.2

6 years ago