n1ru4l / Graphql Schema Generator Rest
Licence: mit
Generate your GraphQL schema from type definitions
Stars: ✭ 94
Programming Languages
javascript
184084 projects - #8 most used programming language
Labels
Projects that are alternatives of or similar to Graphql Schema Generator Rest
Apollo Link Webworker
Apollo link that lets you use graphql client-side only, with a webworker as a "server" supporting normal queries and subscriptions
Stars: ✭ 88 (-6.38%)
Mutual labels: graphql
Django Graphql Social Auth
Python Social Auth support for Graphene Django
Stars: ✭ 90 (-4.26%)
Mutual labels: graphql
Graphql rails
GraphQL on Rails. Write GraphQL server side in rails way
Stars: ✭ 92 (-2.13%)
Mutual labels: graphql
Aws Serverless Airline Booking
Airline Booking is a sample web application that provides Flight Search, Flight Payment, Flight Booking and Loyalty points including end-to-end testing, GraphQL and CI/CD. This web application was the theme of Build on Serverless Season 2 on AWS Twitch running from April 24th until end of August in 2019.
Stars: ✭ 1,290 (+1272.34%)
Mutual labels: graphql
Graphql Java Datetime
GraphQL ISO Date is a set of RFC 3339 compliant date/time scalar types to be used with graphql-java.
Stars: ✭ 89 (-5.32%)
Mutual labels: graphql
Meteor Apollo Starter Kit
Meteor, Apollo, React, PWA, Styled-Components boilerplate
Stars: ✭ 91 (-3.19%)
Mutual labels: graphql
Thunder
⚡️ A Go framework for rapidly building powerful graphql services
Stars: ✭ 1,281 (+1262.77%)
Mutual labels: graphql
Docker
Directus Docker — The Official Docker Container for the Directus Suite
Stars: ✭ 93 (-1.06%)
Mutual labels: graphql
Quell
Quell is an easy-to-use, lightweight JavaScript library providing a client- and server-side caching solution for GraphQL. Use Quell to prevent redundant client-side API requests and to minimize costly server-side response latency.
Stars: ✭ 90 (-4.26%)
Mutual labels: graphql
Graphql Portal
Configurable and distributed GraphQL Gateway. Convert your legacy data sources or monitor your existing GraphQL Services with a visual dashboard.
Stars: ✭ 88 (-6.38%)
Mutual labels: graphql
Prisma Kubernetes Deployment
Demo how to deploy a Prisma server to a Kubernetes cluster.
Stars: ✭ 89 (-5.32%)
Mutual labels: graphql
Wooshop
A Wocommerce Based React Native App for IOS and Android over GraphQL
Stars: ✭ 92 (-2.13%)
Mutual labels: graphql
Angular Fullstack Graphql
🚀 Starter projects for fullstack applications based on Angular & GraphQL.
Stars: ✭ 92 (-2.13%)
Mutual labels: graphql
Sapper Graphql Firebase
Svelte + Sapper + GraphQL + Firebase Auth
Stars: ✭ 88 (-6.38%)
Mutual labels: graphql
Rust graphql api boilerplate
A Boilerplate of GraphQL API built in Rust + Warp + Juniper + Diesel
Stars: ✭ 91 (-3.19%)
Mutual labels: graphql
Nadel
A GraphQL DSL and execution engine for distributed schemas
Stars: ✭ 93 (-1.06%)
Mutual labels: graphql
Unchained
Headless & open-source e-commerce toolkit. The Unchained Engine is our core product and is written in Node.js ES6
Stars: ✭ 92 (-2.13%)
Mutual labels: graphql
Uvicorn Gunicorn Starlette Docker
Docker image with Uvicorn managed by Gunicorn for high-performance Starlette web applications in Python 3.7 and 3.6 with performance auto-tuning. Optionally with Alpine Linux.
Stars: ✭ 92 (-2.13%)
Mutual labels: graphql
Rest GraphQL Schema Generator
This package provides the functionality of generating a GraphQL schema from type definitions annotated with @rest
directives.
Install
yarn add @n1ru4l/graphql-schema-generator-rest
Usage
Creating a schema
import { generateRestSchema } from '@n1ru4l/graphql-schema-generator-rest'
import { graphql } from 'graphql'
import gql from 'graphql-tag'
import fetch from 'node-fetch'
const typeDefs = gql`
type User {
id: ID!
login: String!
friends: [User]!
@rest(
route: "/users/:userId/friends"
provides: { userId: "id" } # map id from parent object to :userId route param
)
}
type Query {
user(id: ID!): User @rest(route: "/users/:id")
}
`
const schema = generateRestSchema({
typeDefs,
fetcher: fetch,
})
const query = `
query user {
user(id: "2") {
id
login
friends {
id
login
}
}
}
`
graphql(schema, query)
.then(console.log)
.catch(console.log)
Available options for generateRestSchema
:
typeDefs |
AST object for GraphQL type definitions generated by graphql-tag
|
fetcher |
WHATWG Fetch Compatible fetch implementation |
queryMappers |
Object of queryMappers that manipulate the query params before a request is sent |
requestMappers |
Object of requestMappers that manipulate the request body object before a request is sent |
responseMappers |
Object of responseMappers that manipulate the response returned by a request |
Type Definitions
type User {
id: ID!
login: String!
friends: [User]!
@rest(
route: "/users/:userId/friends"
provides: { userId: "id" } # map id from parent object to :userId route param
)
}
type Query {
user(id: ID!): User @rest(route: "/users/:id")
}
Available options for the rest
directive:
route |
The route which is called |
provides |
An object that maps fields from the parent object to the scope of the directive |
method |
The HTTP method that will be used (PUT , GET , POST , PATCH ) |
query |
An object that maps fields to the query params |
queryMapper |
The identifier of a a queryMapper that maniplates the query mappings |
body |
An object that maps fields to the request body |
requestMapper |
The identifier of a requestMapper that manipulates the request body |
responseMapper |
The identifier of a responseMapper that manipulates the response body returned by a request |
Recipies
apollo-link-schema
import { generateRestSchema } from '@n1ru4l/graphql-schema-generator-rest'
import { SchemaLink } from 'apollo-link-schema'
import { graphql, print } from 'graphql'
import gql from 'graphql-tag'
import fetch from 'node-fetch'
const typeDefs = gql`
type User {
id: ID!
login: String!
friends: [User]!
@rest(
route: "/users/:userId/friends"
provides: { userId: "id" } # map id from parent object to :userId route param
)
}
type Query {
user(id: ID!): User @rest(route: "/users/:id")
}
`
const schema = generateRestSchema({
typeDefs,
fetcher: fetch,
})
const link = new SchemaLink({ schema })
const query = gql`
query user {
user(id: "2") {
id
login
friends {
id
login
}
}
}
`
makePromise(execute(link, { operationName: `userProfile`, query }))
.then(console.log)
.catch(console.log)
apollo-server-express
import express from 'express'
import bodyParser from 'body-parser'
import { generateRestSchema } from '@n1ru4l/graphql-schema-generator-rest'
import { graphqlExpress, graphiqlExpress } from 'apollo-server-express'
import gql from 'graphql-tag'
import fetch from 'node-fetch'
const typeDefs = gql`
type User {
id: ID!
login: String!
friends: [User]!
@rest(
route: "/users/:userId/friends"
provides: { userId: "id" } # map id from parent object to :userId route param
)
}
type Query {
user(id: ID!): User @rest(route: "/users/:id")
}
`
const schema = generateRestSchema({
typeDefs,
fetcher: fetch,
})
const PORT = 3000
const app = express()
app.use('/graphql', bodyParser.json(), graphqlExpress({ schema }))
app.listen(PORT)
Tests
yarn test
Contribute
Checkout project
For contributions please fork this repository.
git clone https://github.com/<your-login>/graphql-schema-generator-rest.git
cd graphql-schema-generator-rest
yarn install
Commiting Changes
Please use yarn cm
for commiting changes to git.
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].