Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apollo-modulizer

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-modulizer

Modularizing your Apollo GraphQL schema code

  • 0.2.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

apollo-modulizer

Modularizing your Apollo GraphQL schema code

yarn add apollo-modulizer
npm install --save apollo-modulizer

Usage

You can get the full example here: https://github.com/Maxvien/apollo-modulizer/tree/master/example

Create A Module

const { gql } = require('apollo-server');
const { createModule } = require('apollo-modulizer');

const typeDef = gql`
  type User {
    id: ID!
    name: String
    posts: [Post]
  }
  input UserInput {
    name: String
  }
`;

const resolvers = {
  User: {
    posts: () => [
      { id: 1, title: 'Apollo Server', content: 'Hello Apollo Server!' },
    ],
  },
};

module.exports = createModule({ typeDef, resolvers });

Merge All Modules

const { allModules } = require('apollo-modulizer');

const User = require('./user.module');
const Post = require('./post.module');
const Query = require('./query.module');

module.exports = { typeDefs, resolvers } = mergeModules([User, Post, Query]);

Launch With Apollo Server

const { ApolloServer } = require('apollo-server');
const { typeDefs, resolvers } = require('./modules');

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

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

Keywords

FAQs

Package last updated on 27 Aug 2019

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc