Socket
Socket
Sign inDemoInstall

apollo-server-core

Package Overview
Dependencies
20
Maintainers
2
Versions
314
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    apollo-server-core

Core engine for Apollo GraphQL server


Version published
Weekly downloads
1M
decreased by-2.94%
Maintainers
2
Install size
12.4 MB
Created
Weekly downloads
 

Package description

What is apollo-server-core?

The apollo-server-core package is a core library for Apollo Server, which is a community-driven, open-source GraphQL server. It works with various Node.js HTTP server frameworks and provides features necessary to run a GraphQL server, such as schema definition, request processing, and query execution. It's designed to simplify the process of building efficient, scalable GraphQL APIs.

What are apollo-server-core's main functionalities?

Schema Definition

Allows defining a GraphQL schema using the GraphQL schema language. This is the first step in setting up a GraphQL server.

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

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

const server = new ApolloServer({ typeDefs });

Resolvers Implementation

Defines the technique for fetching the types defined in the schema. This code sample shows how to implement a simple resolver.

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

const server = new ApolloServer({ typeDefs, resolvers });

Server Setup and Running

Illustrates how to start the Apollo Server and listen on a port. It logs the URL where the server can be accessed.

server.listen().then(({ url }) => {
  console.log(`🚀  Server ready at ${url}`);
});

Integrating with Middleware

Shows how to integrate Apollo Server with an Express application using `apollo-server-express`, demonstrating Apollo Server's flexibility with HTTP server frameworks.

const { ApolloServer } = require('apollo-server-express');
const express = require('express');

const app = express();
const server = new ApolloServer({ typeDefs, resolvers });

server.applyMiddleware({ app });

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

Other packages similar to apollo-server-core

Readme

Source

apollo-server-core

npm version Build Status

This is the core module of the Apollo community GraphQL Server. Read the docs. Read the CHANGELOG.

Keywords

FAQs

Last updated on 07 May 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc