All Projects → lucasconstantino → Graphql Modules

lucasconstantino / Graphql Modules

Licence: mit
⚠️ [DEPRECATED] GraphQL module library for Apollo.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Graphql Modules

react-native-apple-sign-in
Apple Signin for your React Native applications
Stars: ✭ 16 (-69.81%)
Mutual labels:  deprecated, archived, obsolete
Tinx
⛔️ Laravel Tinx is archived and no longer maintained.
Stars: ✭ 437 (+724.53%)
Mutual labels:  deprecated, archived, obsolete
VRTK.Prefabs
*Deprecated* - A collection of productive prefabs for rapidly building spatial computing solutions in the Unity software.
Stars: ✭ 61 (+15.09%)
Mutual labels:  deprecated, archived, obsolete
Graphql Config
One configuration for all your GraphQL tools (supported by most tools, editors & IDEs)
Stars: ✭ 883 (+1566.04%)
Mutual labels:  graphql, apollo, graphql-schema
Mern Cli
⛔️ DEPRECATED - A cli tool for getting started with MERN
Stars: ✭ 575 (+984.91%)
Mutual labels:  deprecated, archived, obsolete
Sphero-AR-SDK
🚫 DEPRECATED: Sphero's augmented reality SDK
Stars: ✭ 46 (-13.21%)
Mutual labels:  deprecated, archived, obsolete
Piranha
[DEPRECATED] This is the legacy version of Piranha CMS for .NET 4.5, MVC 5.2 & WebPages 3.2.
Stars: ✭ 418 (+688.68%)
Mutual labels:  deprecated, archived, obsolete
ionic-3D-card-carousel
DEPRECATED Sample project that shows an experimental 3D card carousel in Ionic.
Stars: ✭ 29 (-45.28%)
Mutual labels:  deprecated, archived, obsolete
Aawindow
[Deprecated] · UIWindow subclass to enable behavior like adaptive round-corners & detecting when Control Center is opened.
Stars: ✭ 486 (+816.98%)
Mutual labels:  deprecated, archived, obsolete
Pygeoip
DEPRECATED: Pure Python API for Maxmind's binary GeoIP databases
Stars: ✭ 483 (+811.32%)
Mutual labels:  deprecated, archived, obsolete
QR
DEPRECATED The bookmarklet and extensions generate QRCode of the current URL for viewing on mobile devices (Google Chrome/Mozilla Firefox/Opera/Safari)
Stars: ✭ 20 (-62.26%)
Mutual labels:  deprecated, archived, obsolete
Mern Starter
⛔️ DEPRECATED - Boilerplate for getting started with MERN stack
Stars: ✭ 5,175 (+9664.15%)
Mutual labels:  deprecated, archived, obsolete
VRTK.Tutorials.OculusIntegration
Prefabs and code for use with the Oculus Integration Unity Package
Stars: ✭ 26 (-50.94%)
Mutual labels:  deprecated, archived, obsolete
AASecondaryScreen
[Deprecated] · Approachable implementation of iOS AirPlay-Mirroring using Swift.
Stars: ✭ 40 (-24.53%)
Mutual labels:  deprecated, archived, obsolete
Azure-AppServices-Diagnostics
Azure App Service Diagnostics provides developers ability to write various diagnostics features which helps customers to diagnose and troubleshoot their applications hosted on app services.
Stars: ✭ 42 (-20.75%)
Mutual labels:  deprecated, archived, obsolete
Sphero.js
🚫 DEPRECATED: The Sphero JavaScript SDK to control Sphero robots.
Stars: ✭ 346 (+552.83%)
Mutual labels:  deprecated, archived, obsolete
Sphero-Win-SDK
🚫 DEPRECATED: Sphero SDK for Win 8.1+ using RFCOMM
Stars: ✭ 36 (-32.08%)
Mutual labels:  deprecated, archived, obsolete
jest-badges-readme
Creates a group of coverage badges from Jest into your README
Stars: ✭ 30 (-43.4%)
Mutual labels:  deprecated, archived, obsolete
Get Graphql Schema
Fetch and print the GraphQL schema from a GraphQL HTTP endpoint. (Can be used for Relay Modern.)
Stars: ✭ 443 (+735.85%)
Mutual labels:  graphql, apollo, graphql-schema
Docker Cleanup
DEPRECATED Automatic Docker image, container and volume cleanup
Stars: ✭ 582 (+998.11%)
Mutual labels:  deprecated, archived, obsolete

DEPRECATED

⚠️ This project is no longer maintained. We recommend you use Urigo/graphql-modules instead.


GraphQL Modules

A library to simplify modularization of Apollo server applications.

No Maintenance Intended Build status

Installation

This package is available on npm as: graphql-modules

npm install graphql-modules

You should consider using yarn, though.

Basic usage

// module-a.js
// -----------
const moduleA = {
  queries: `
    helloWorld: String
  `
  resolvers: {
    queries: {
      helloWorld: () => 'Hello World!'
    }
  }
}

export default moduleA

// module-b.js
// -----------
const moduleB = {
  queries: `
    helloYou(name: String): String
  `,
  resolvers: {
    queries: {
      helloYou: (root, { name }) => `Hello ${name}!`
    }
  }
}

export default moduleB

// schema.js
// ---------
import { bundle } from 'graphql-modules'
import { makeExecutableSchema } from 'graphql-tools'

import moduleA from './module-a'
import moduleB from './module-b'

const modules = [moduleA, moduleB]


export default makeExecutableSchema(bundle(modules))

Complex needs

This library handles complex situations such as cyclic dependencies between modules. For that to work, each module can be a factory function - besides being a module object. That allows for dependencies to be handled on runtime, making ES6 module binding work as desired. This is pretty much what is proposed by the official Apollo docs.

Say you have a system with books and authors - two modules that are interdependent; books have authors and authors have books. You could end up with something like this:

/books.js

import authors, { data as authorList } from './authors'

export const data = [
  { id: 1, title: 'JavaScript: The Good Parts', author: 1 },
  { id: 2, title: 'End to end testing with Protractor', author: 2 }
]

const schema = `
  type Book {
    id: String
    title: String
    author: Author
  }
`

export const queries = `
  books: [Book]
  book(id: Int): Book
`
const books = () => data
const book = (root, args) => data.find(book => book.id === args.id)

const resolvers = {
  queries: {
    books,
    book
  },
  Book: {
    author: book => authorList.find(author => author.id === book.author)
  }
}

export default () => ({
  schema,
  queries,
  resolvers,
  modules: [authors]
})

In this file, we define a schema, queries, and resolvers. At the end, we export those assets in a single object - the module.

/authors.js

import books, { data as bookList } from './books'

export const data = [
   { id: 1, name: 'Douglas Crockford' },
   { id: 2, name: 'Walmyr Lima' }
]

const schema = `
   type Author {
     id: String
     name: String
     books: [Book]
   }
`

export const queries = `
   authors: [Author]
   author(id: Int): Author
`
const authors = () => data
const author = (root, args) => data.find(author => author.id === args.id)

const resolvers = {
  queries: {
    authors,
    author
  },
  Author: {
    books: author => bookList.filter(book => book.author === author.id)
  }
}

export default () => ({
  schema,
  queries,
  resolvers,
  modules: [books]
})

This file is almost copy and paste from the previous.

/schema.js

import { bundle } from 'graphql-modules'
import { makeExecutableSchema } from 'graphql-tools'

import books from './books'

const modules = [books]

export default makeExecutableSchema(bundle(modules))

At this last file, we create our schema (for this example, we are using graphql-tools's makeExecutableSchema).

Further steps

This project is a work in process, a proof of concept, and can be expanded as wish. I believe this should some day be integrated into the graphql-tools project somehow.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].