JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q32218F
  • License MIT

Apollo Server integration for HTTP, HTTPS and HTTP2

Package Exports

  • apollo-server-native

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (apollo-server-native) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Apollo Server integration for HTTP, HTTPS and HTTP2

npm version

This integration of Apollo Server works with native HTTP, HTTPS and HTTP2.

Installation

Install apollo-server-native package with yarn or npm

Example with HTTP

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

const typeDefs = gql`
  type Query {
    "A simple type for getting started!"
    hello: String
  }
`

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

const server = http.createServer()
const apolloServer = new HttpApolloServer({ typeDefs, resolvers })

apolloServer.applyMiddleware({
  server
})

server.listen(3000, () =>
  console.log(`🚀 server ready at http://localhost:3000`)
)

Example with HTTPS

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

const typeDefs = gql`
  type Query {
    "A simple type for getting started!"
    hello: String
  }
`

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

const server = https.createServer({})
const apolloServer = new HttpApolloServer({ typeDefs, resolvers })

apolloServer.applyMiddleware({
  server
})

server.listen(3000, () =>
  console.log(`🚀 server ready at https://localhost:3000`)
)

Example with HTTP2

const http2 = require('http2')
const { Http2ApolloServer, gql } = require('apollo-server-native')

const typeDefs = gql`
  type Query {
    "A simple type for getting started!"
    hello: String
  }
`

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

const server = http2.createSecureServer({})
const apolloServer = new Http2ApolloServer({ typeDefs, resolvers })

apolloServer.applyMiddleware({
  server
})

server.listen(3000, () =>
  console.log(`🚀 server ready at https://localhost:3000`)
)