Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/graphitejs/server
Framework NodeJS for GraphQl
https://github.com/graphitejs/server
framework graphql graphql-server javascript nodejs
Last synced: 2 months ago
JSON representation
Framework NodeJS for GraphQl
- Host: GitHub
- URL: https://github.com/graphitejs/server
- Owner: graphitejs
- License: mit
- Created: 2017-03-21T15:39:19.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-02T17:18:09.000Z (2 months ago)
- Last Synced: 2024-10-06T22:01:52.544Z (2 months ago)
- Topics: framework, graphql, graphql-server, javascript, nodejs
- Language: JavaScript
- Homepage:
- Size: 8.21 MB
- Stars: 120
- Watchers: 10
- Forks: 56
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-graphql - GraphiteJS - Framework NodeJS for GraphQl. (Libraries / JavaScript Libraries)
- awesome-graphql - graphitejs - Framework NodeJS for GraphQL. (Implementations / JavaScript/TypeScript)
- awesome-list - server
- awesome-graphql - GraphiteJS - Framework NodeJS for GraphQl. (Libraries / JavaScript Libraries)
README
Framework NodeJS for GraphQl
GraphiteJS is a NODE.JS Framework for building GraphQL schemas/types fast, easily and with scalability.
- **Easy to use:** GraphiteJS make easy GraphQL in NodeJS without effort.
- **Any Front:** GraphiteJS support any front library.
- **Data agnostic:** GraphiteJS supports any kind of data source.---
## Guide- [Install](#install)
- [How to use](#how-to-use)
- [Types](#types)
- [Queries](#queries)
- [Mutations](#mutations)
- [Subscriptions](#subscriptions)
- [Relations](#relations)
- [Contributing](#contributing)
- [Team](#team)---
## Install
```bash
npm i @graphite/server --save
yarn add @graphite/server
```
on your index file:
```javascript
import { Graphite } from '@graphite/server'
main = async () => {
const graphite = await Graphite()
}main()
```
and that's all, you have running the graphqli tool on the port [4000](http://localhost:4000/graphqle) by default.
## How to use
After install `@graphite/server` you have to create your first model. We recommend creating a folder called models and follow the pattern matching the filename with the Type name.
#### Types
```javascript
import { GraphQL } from '@graphite/server'
export const Developer = GraphQL('Developer')({
// the value always have to be an array first arg is the type, the second arg is an optional comment
name: ['String!', 'Your name is required'],
age: ['Int'],
isGreatDeveloper: ['Boolean']
})```
So, now you need to pass this model to the Graphite Server
on `index.js`
```javascript
import { Graphite } from '@graphite/server'
import { Developer } from './models/Developer'main = async () => {
await Graphite({ models: [Developer] })
}main()
```
#### Queries
```javascript
import { GraphQL } from '@graphite/server'
export const Developer = GraphQL('Developer')({
name: ['String!', 'Your name is required'],
age: ['Int'],
isGreatDeveloper: ['Boolean'],Query: {
'developer: Developer': () => ({ name: 'Your name' }),
'developers: [Developer]': () => ([{ name: 'Your name' }]),
}
})```
#### Mutations
```javascript
import { GraphQL } from '@graphite/server'
export const Developer = GraphQL('Developer')({
name: ['String!', 'Your name is required'],Mutation: {
'createDeveloper(name: String): Developer': (_, { name, }) => ({ name }),
'updateDeveloper(id: ID!, name: String): Developer': (_, { name }) => ({ name }),
'removeDeveloper(id: ID!): Developer': (_, { name }) => ({ name }),
},
})```
#### Subscriptions
```javascript
import { GraphQL, PubSub } from '@graphite/server'
const pubsub = new PubSub()
const DEVELOPER_ADDED = 'DEVELOPER_ADDED'export const Developer = GraphQL('Developer')({
name: ['String!', 'Your name is required'],Mutation: {
'createDeveloper(name: String): Developer': (_, { name, }) => {
pubsub.publish(DEVELOPER_ADDED, { developerAdded: { name } })
return { name }
},
},Subscription: {
'developerAdded: Developer': {
subscribe: () => pubsub.asyncIterator([DEVELOPER_ADDED]),
},
},
})```
#### Relations
```javascript
// models/Repository.js
const Repository = GraphQL('Repository')({
name: ['String'],
url: ['String'],
})// models/GithubProfile.js
const GithubProfile = GraphQL('GithubProfile')({
url: ['String'],
})// models/Developer.js
const Developer = GraphQL('Developer')({
name: ['String'],'respositories: [Repository]': () => [{ name: 'GraphiteJS', url: 'https://github.com/graphitejs/graphitejs' }],
'githubProfile: GithubProfile': () => ({ url: 'https://github.com/wzalazar' }),
Query: {
'developer: Developer': () => ({ name: 'Walter Zalazar' }),
},
})```
So, now you need to pass this model to the Graphite Server
on `index.js`
```javascript
import { Graphite } from '@graphite/server'
import { Developer } from './models/Developer'
import { Repository } from './models/Repository'
import { GithubProfile } from './models/GithubProfile'main = async () => {
await Graphite({ models: [Developer, Repository, GithubProfile] })
}main()
```
## Contributing
Please see our [contributing.md](./CONTRIBUTING.md)
- Clone this repository.
- Install dependencies.```bash
npm install
```
- Feel free for pull request.
## Team
### Creator
[![Walter Zalazar](https://avatars.githubusercontent.com/u/5795257?s=64)](https://github.com/wzalazar) |
|---|
Walter Zalazar |
:octocat: [@wzalazar](https://github.com/wzalazar) |
:bird: [@wzalazar_](https://twitter.com/wzalazar_) |### Core members
| [![Walter Zalazar](https://avatars.githubusercontent.com/u/5795257?s=64)](https://github.com/wzalazar) | [![Jose Casella](https://avatars.githubusercontent.com/u/23145933?s=64)](https://github.com/jl-casella) |
|---|---|
| Walter Zalazar | José Luis Casella |
| :octocat:[@wzalazar](https://github.com/wzalazar) | [@jl-casella](https://github.com/jl-casella) |
| :bird:[@wzalazar_](https://twitter.com/wzalazar_) | [@jl-casella](https://twitter.com/jl-casella) |## License
[MIT](https://github.com/babel/babel/blob/master/LICENSE)