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

@midgar/apollo-server

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@midgar/apollo-server

A Midgar plugin to add graphql server

  • 1.0.0-alpha.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Build Status Coverage

@midgar/apollo-server

PLugin Midgar pour ajouter un service Apollo serveur avec loader de modules graphql et injéction de services.

Installation

$ npm i @midgar/apollo-server --save

Si tout s'est bien passé, un message de confirmation s'affiche:

#midgar-cli
@midgar/apollo-server added to plugins.js !

Fonctionnement

Ajoute un dossier de plugin midgar-graphql: ./graphql/ pour les modules graphl.

module grapql

Un module graphql est un fichier javacript exportant les typeDefs et les resolvers graphql.

Exemple d'un module graphl:

import { gql } from 'apollo-server-express'

// Type defs graphql
const typeDefs = gql`
  type User {
    id: ID!
    email: String!
  }

  extend type Query {
    addUser(email: String): User
    getUsers: [User]
  }
`

export default {
  // Services à incjecter
  dependencies: ['mid:user']
  graphql: (mid, userService) => {
    return {
      typeDefs,
      resolvers:{
        User: {
        ...
        }
        Query: {
          createUser: async (parent, args, ctx, info) => {
            await userService.create(args.email, args.parssword)
          },
          getUsers: (parent, args, ctx, info) => {
            ...
          },
        }
      }
    }
  }
}

Vous pouvez séparrer le fichier si besoin:

import typeDefs from './user.typedefs'
import resolvers from './user.resolvers'

export default {
  dependencies: ['mid:user']
  graphql: (...args) => {
    return {
      typeDefs,
      resolvers: () => resolvers(...args)
    }
  }
}

Les fichiers *.typedefs.js et *.resolvers.js ne sont pas importé lors de l'import des modules graphql.

Keywords

FAQs

Package last updated on 05 Jan 2020

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