项目作者: cult-of-coders

项目描述 :
Meteor & Apollo integration
高级语言: JavaScript
项目地址: git://github.com/cult-of-coders/apollo.git
创建时间: 2018-03-26T11:11:07Z
项目社区:https://github.com/cult-of-coders/apollo

开源协议:MIT License

下载


Meteor Apollo

License: MIT

Build Status

Features

  • Plug and Play Zero-Config GraphQL Server
  • GraphQL Playground + Subscription Support
  • MongoDB Relational Support - Grapher
  • Scalable Reactive Queries - RedisOplog
  • HTTP & Subscription authentication support with Meteor Accounts
  • Built-in convenience Date and JSON scalars

Install

If you do not have Meteor up and running, install it from here

  1. meteor create --bare graphql-baby
  2. cd graphql-baby
  3. # Now we install our npm dependencies for server
  4. meteor npm i -S graphql graphql-load apollo-server-express uuid graphql-tools graphql-type-json apollo-live-server
  5. # Dependencies for the client
  6. meteor npm i -S react-apollo apollo-live-client apollo-client apollo-cache-inmemory apollo-link apollo-link-http apollo-link-ws apollo-morpher subscriptions-transport-ws apollo-upload-client
  7. # Now we add the package
  8. meteor add cultofcoders:apollo
  9. # Optional but highly recommended (so you can import .gql/.graphql files)
  10. meteor add swydo:graphql
  11. # If you're looking into Server Side Rendering with React
  12. meteor npm i -S react react-dom react-apollo react-router apollo-link-schema

Let’s setup a basic query and initialize our GraphQL server:

  1. // file: server/main.js
  2. import { initialize } from 'meteor/cultofcoders:apollo';
  3. import { load } from 'graphql-load';
  4. load({
  5. typeDefs: `
  6. type Query {
  7. sayHello: String
  8. }
  9. `,
  10. resolvers: {
  11. Query: {
  12. sayHello: () => 'Hello world!',
  13. },
  14. },
  15. });
  16. initialize();

Now you can safely run your project:

  1. meteor run

Now get on your browser and go to: http://localhost:3000/graphql and give it a spin:

  1. query {
  2. sayHello
  3. }

Documentation

Click here to go to the documentation

Useful packages

Premium Support

Looking to start or develop your new project with GraphQL? Reach out to us now, we can help you along every step: contact@cultofcoders.com. We specialise in building high availability GraphQL APIs and with the help with our awesome frontend developers we can easily consume any GraphQL API.