All Projects → StevenLambion → GraphQLRouteCollection

StevenLambion / GraphQLRouteCollection

Licence: MIT license
A GraphQL based RouteCollection for Vapor

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to GraphQLRouteCollection

paginator
Offset pagination for Vapor 🗂
Stars: ✭ 67 (+272.22%)
Mutual labels:  vapor, server-side-swift
Mysql Kit
🐬 Pure Swift MySQL client built on non-blocking, event-driven sockets.
Stars: ✭ 159 (+783.33%)
Mutual labels:  vapor, server-side-swift
Mistkit
Swift Package for Server-Side and Command-Line Access to CloudKit Web Services
Stars: ✭ 129 (+616.67%)
Mutual labels:  vapor, server-side-swift
async
⏱ Promises and reactive-streams in Swift built for high-performance and scalability.
Stars: ✭ 35 (+94.44%)
Mutual labels:  vapor, server-side-swift
Console Kit
💻 APIs for creating interactive CLI tools.
Stars: ✭ 252 (+1300%)
Mutual labels:  vapor, server-side-swift
Flock
Automated deployment of Swift projects to servers
Stars: ✭ 127 (+605.56%)
Mutual labels:  vapor, server-side-swift
Websocket Kit
WebSocket client library built on SwiftNIO
Stars: ✭ 155 (+761.11%)
Mutual labels:  vapor, server-side-swift
Vapor Oauth
OAuth2 Provider Library for Vapor
Stars: ✭ 90 (+400%)
Mutual labels:  vapor, server-side-swift
Telegrammer
Telegram Bot - written with Swift 5.2 / NIO, supports Linux, macOS
Stars: ✭ 248 (+1277.78%)
Mutual labels:  vapor, server-side-swift
Htmlkit
A type-safe DSL that renders dynamic HTML templates in Swift
Stars: ✭ 229 (+1172.22%)
Mutual labels:  vapor, server-side-swift
Open Crypto
🔑 Hashing (BCrypt, SHA2, HMAC), encryption (AES), public-key (RSA), and random data generation.
Stars: ✭ 115 (+538.89%)
Mutual labels:  vapor, server-side-swift
sqlite-kit
Non-blocking SQLite client library with SQL builder built on SwiftNIO
Stars: ✭ 51 (+183.33%)
Mutual labels:  vapor, server-side-swift
Sql Kit
*️⃣ Build SQL queries in Swift. Extensible, protocol-based design that supports DQL, DML, and DDL.
Stars: ✭ 115 (+538.89%)
Mutual labels:  vapor, server-side-swift
fluent-postgres-driver
🐘 PostgreSQL driver for Fluent.
Stars: ✭ 120 (+566.67%)
Mutual labels:  vapor, server-side-swift
Vaporsecurityheaders
Harden Your Security Headers For Vapor
Stars: ✭ 107 (+494.44%)
Mutual labels:  vapor, server-side-swift
Api Template
💧 A starting point for Vapor APIs.
Stars: ✭ 130 (+622.22%)
Mutual labels:  vapor, server-side-swift
Aws
Swift wrapper around AWS API
Stars: ✭ 67 (+272.22%)
Mutual labels:  vapor, server-side-swift
Vapor Clean
A Vapor 3 template with no additional cruft.
Stars: ✭ 80 (+344.44%)
Mutual labels:  vapor, server-side-swift
Http
🚀 Non-blocking, event-driven HTTP built on Swift NIO.
Stars: ✭ 220 (+1122.22%)
Mutual labels:  vapor, server-side-swift
VaporTwilioService
Twilio API provider for all your Vapor needs
Stars: ✭ 19 (+5.56%)
Mutual labels:  vapor, server-side-swift

GraphQLRouteCollection

Provides a simple route collection to integrate GraphQLSwift into a Vapor application.

Swift License

Installation

Add GraphQLRouteCollection to your Package.swift

import PackageDescription

let package = Package(
    dependencies: [
        ...
        .package(url: "https://github.com/stevenlambion/GraphQLRouteCollection.git", .upToNextMajor(from: "0.0.1")),
    ],
    .target(
        name: "App",
        dependencies: [..., "GraphQLRouteCollection"],
    ),
)

Usage

Add the GraphQLRouteCollection to your droplet. Your schema, rootValue, and context are provided through a closure to allow per request dynamic execution. A common use case is setting up dataloaders for each request.

Basic

import Vapor
import GraphQLRouteCollection

extension Droplet {
    func setupRoutes() throws {

        // By default, the collection uses "graphql" as its path.
        // Pass a custom path as the first argument to change it.

        try collection(
            GraphQLRouteCollection() { req in (
                schema: schema,
                rootValue: [:],
                context: [:]
            )}
        )

    }
}

GraphiQL

Enables the GraphiQL IDE when a user accesses the graphql path in a web browser.

GraphQLRouteCollection(enableGraphiQL: true) { req in (
    schema: schema,
    rootValue: [:],
    context: [:]
)}

Introspection Query

The route collection enables a quick way to introspect your entire graphql schema. This is useful in development when you need to auto-generate a schema for graphql clients such as Apollo. Here's an example of how to enable for development use.

GraphQLRouteCollection(enableIntrospectionQuery: true) { req in (
    schema: schema,
    rootValue: [:],
    context: [:]
)}

To retrieve the introspected schema simply hit the graphql endpoint without a provided query. It will instead use an internal introspection query.

  fetch("localhost:8080/graphql") { resp in
    let schema = parseSchema(resp.json)
  }

The Kitchen Sink

GraphQLRouteCollection("graphql", enableGraphiQL: true, enableIntrospectionQuery: true) { req in (
    schema: schema,
    rootValue: [:],
    context: ["dataLoaders": createDataLoaders(req)]
)}

License

This project is released under the MIT license. See LICENSE for details.

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].