Skip to content

VikR1000/Mantra-Apollo-Starter-Kit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Written with StackEdit.

MANTRA APOLLO STARTER KIT

A fast way to start with Apollo in a Mantra application.

INSTALL THE STARTER KIT

meteor npm install

The npm package "pg" may need Python installed on your system. In case you get npm install errors referring to Python, here are links for installing Python on your system:

You may need to set up the path to Python. In the terminal:

$ which python

The system will respond with the path to Python. Then, still in the terminal, enter:

$ npm config set python [PATH TO PYTHON]
You must install a postgres database prior to running this app. See the next section for instructions.

INSTALL POSTGRES

Next, Create a postgres database and user on your development machine.

Open the file in the starter kit, Mantra-Apollo-Starter-Kit/imports/api/db-connectors.js, and find the line beginning:

export const db = new Sequelize('database', 'username', 'password', [.....]

Replace 'database', 'username', 'password' with the info for the database you just set up.

Want to install an SQL management app on your development machine? It can be helpful to have an app like this to inspect what's in your database.

Accessing GraphIQL

Apollo includes GraphIQL, a fast way of building and testing queries. Access it at localhost:3000/graphql

LEARNING GRAPHQL

GraphQL expects connectors, schema, queries and resolvers to work together.

  • Connectors. In this project, connectors are in the file /imports/api/db-connectors. You will find examples of how to connect to MongoDB, Rest, and SQL databases.
  • Schema. In this project, schema is in the file /imports/api/schema.js. You will find examples of how to set up a relational database of Authors and Posts.
  • Queries. Sample queries are in the component, /client/modules/core/components/main_layout.jsx. You will find an example query that pulls up relational data for an author and for the posts of that author. You will also find an example Mutation that adds an author. Check your browser console to see the resulting data for these two queries.
  • Resolvers. In this project, resolvers are in the file /imports/api/resolvers.js. You will find an example of how to resolve queries for relational data, as well as for a mutatation that adds data.

APOLLO RESOURCES

YOUR CONTRIBUTIONS ARE WELCOME!

About

A fast way to get started with Apollo in Mantra.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published