Skip to content

JonnyBGod/loopback-graphql-relay

This branch is 162 commits ahead of muneebs/loopback-graphql-relay:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8c1bda3 Β· Jun 8, 2020
Mar 8, 2018
Mar 14, 2017
Mar 14, 2017
Mar 15, 2019
Mar 14, 2017
Nov 3, 2018
Jun 8, 2020
Sep 19, 2019
Mar 14, 2017
Apr 3, 2018
Sep 26, 2018
Mar 14, 2017
Mar 14, 2017
Jan 8, 2018
Mar 14, 2017
Jun 8, 2020
Mar 14, 2017
Mar 14, 2017
Jan 3, 2019
Sep 19, 2019
Apr 3, 2018
Mar 14, 2017
Jun 8, 2020
Jun 8, 2020
Jun 19, 2018

Repository files navigation

Status 🎊

npm version Build Status bitHound Overall Score bitHound Dependencies bitHound Dev Dependencies bitHound Code Known Vulnerabilities

Relay GraphQL Server for Loopback (Apollo Server)

Combine the powers of ApolloStack GraphQL with the backend of Loopback to automatically generate GraphQL endpoints based on Loopback Schema.

Loopback Graphql

Queries πŸ’₯

  • Relay Specification: node query to fetch single entity by ID
  • viewer query to fetch all models for a viewer
  • Filter support for where and order filters on queries
  • Support for relations and querying related data
  • Relay Connections support for listed data
  • Relay Pagination (first, last, before, after)
  • Remote methods integration

Mutations πŸš€

  • Nested and clean schema structure
  • Maps all post, put, patch and delete methods to mutations
  • Remote methods integration

Subscriptions ⚑️

  • create, update and remove events of all shared models.

Other Features πŸŽ‰

Loopback Types

  • Any
  • Array
  • Boolean
  • Buffer
  • Date
  • GeoPoint
  • Null
  • Number
  • Object
  • String

Loopback Relations

  • BelongsTo
  • HasOne
  • HasMany
  • HasManyThrough
  • HasAndBelongsToMany
  • Polymorphic
  • EmbedsOne
  • EmbedsMany
  • ReferencesMany

Misc

  • Accepts AccessToken for authenticated API calls
  • Resolves and respects ACLs

Todo

  • File uploads

Usage πŸ’»

npm install loopback-graphql-relay

Add the loopback-graphql-relay component to the server/component-config.json:

"loopback-graphql-relay": {
    "path": "/graphql",
    "subscriptionServer": {
      "disable": false,
      "auth": false
    },
    "viewer": {
      "UserModel": "Account"
    }
  }

Requests will be posted to path path. (Default: /graphql);

GraphQl Playground is available on path path. (Default: /graphql);

Apollo's Subscription Server can be customised by passing subscriptionServer configuration. More information can be found at Subscriptions Docs.

const { RedisPubSub } = require('graphql-redis-subscriptions')
const path = require('path')
const fs = require('fs')
...

subscriptionServer: {
  disable: false,
  https: {
    key: fs.readFileSync(path.join(__dirname, '.certs/example.key')).toString(),
    cert: fs.readFileSync(path.join(__dirname, '.certs/example.crt')).toString()
  },
  pubsub: new RedisPubSub({
    connection: {
      host: 'cluster-redis-master.default.svc.cluster.local',
      retry_strategy: options => {
        // reconnect after
        return Math.max(options.attempt * 100, 3000)
      }
    }
  })
},

Apollo's persistent queries can be customised by passing persistedQueries configuration. More information can be found at Performance Docs.

const { RedisCache } = require('apollo-server-cache-redis')
...

persistedQueries: {
  cache: new RedisCache({
    host: 'cluster-redis-master.default.svc.cluster.local',
    retry_strategy: options => {
      // reconnect after
      return Math.max(options.attempt * 100, 3000)
    }
  })
}

Inspiration πŸ™Œ

This repository originally started as a fork of the loopback-graphql project by Tallyb. But due to considerable change in the way query end points are created, this repository is maitained as an independant project.

Roadmap πŸ›£

See here the Github project

About

Add Relay based Apollo Server or GraphQL queries on your Loopback server

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%