All Projects → JanGorman → Chester

JanGorman / Chester

Licence: mit
Chester is a Swift GraphQL query builder.

Programming Languages

swift
15916 projects
dsl
153 projects

Projects that are alternatives of or similar to Chester

Springboot Projects Fullstack
Spring Boot, JDBC, ORM, JPA, Hibernate, H2, MySQL, Oracle
Stars: ✭ 76 (-6.17%)
Mutual labels:  graphql
Graphql Rxjs
fork of Graphql which adds Observable support
Stars: ✭ 78 (-3.7%)
Mutual labels:  graphql
Aspnetcoregraphql Myhotel
A sample ASP.NET Core & Angular app for demonstrating GraphQL API service
Stars: ✭ 80 (-1.23%)
Mutual labels:  graphql
Graphqlicious
A swift component with a DSL to declare GraphQL queries and to get string representations out of them
Stars: ✭ 76 (-6.17%)
Mutual labels:  graphql
Graphql client
GraphQL Client.
Stars: ✭ 78 (-3.7%)
Mutual labels:  graphql
React Music
react开发app版的网易云音乐
Stars: ✭ 79 (-2.47%)
Mutual labels:  graphql
Daptin
Daptin - Backend As A Service - GraphQL/JSON-API Headless CMS
Stars: ✭ 1,195 (+1375.31%)
Mutual labels:  graphql
Write With Me
Real-time Collaborative Markdown Editor
Stars: ✭ 81 (+0%)
Mutual labels:  graphql
Requent
A GraphQL like interface to map a request to eloquent query with data transformation for Laravel.
Stars: ✭ 78 (-3.7%)
Mutual labels:  graphql
Nestjs Cqrs Starter
NestJS CQRS Microservices Starter Project
Stars: ✭ 80 (-1.23%)
Mutual labels:  graphql
Fullstack Graphql Airbnb Clone
A Fullstack GraphQL Airbnb Clone with React and React Native
Stars: ✭ 1,205 (+1387.65%)
Mutual labels:  graphql
Moviesapp
React Native Movies App: AWS Amplify, AWS AppSync, AWS Cognito, GraphQL, DynamoDB
Stars: ✭ 78 (-3.7%)
Mutual labels:  graphql
Realm Graphql
GraphQL client for Realm Object Server
Stars: ✭ 79 (-2.47%)
Mutual labels:  graphql
Apollo Tote
👜 A declarative approach to handling Apollo GraphQL queries in React
Stars: ✭ 76 (-6.17%)
Mutual labels:  graphql
Firegraph
GraphQL Superpowers for Google Cloud Firestore
Stars: ✭ 80 (-1.23%)
Mutual labels:  graphql
Nextjs Strapi Boilerplate
🎨 Boilerplate for building applications using Strapi and Next.js
Stars: ✭ 76 (-6.17%)
Mutual labels:  graphql
Purescript Graphql
End to End typesafe GraphQL with PureScript
Stars: ✭ 79 (-2.47%)
Mutual labels:  graphql
Spacy Graphql
🤹‍♀️ Query spaCy's linguistic annotations using GraphQL
Stars: ✭ 81 (+0%)
Mutual labels:  graphql
Graphql Lazyloader
GraphQL directive that adds Object-level data resolvers.
Stars: ✭ 81 (+0%)
Mutual labels:  graphql
Graphdoc
Static page generator for documenting GraphQL Schema
Stars: ✭ 1,218 (+1403.7%)
Mutual labels:  graphql

Chester

CI codecov.io Carthage compatible Version License Platform

Experimental: @functionBuilder support

@functionBuilder seems like a natural match for this kind of task. There's a separate GraphQLBuilderTests test suite that shows the supported cases. In it's basic form you can construct a query like this:

import Chester

let query = GraphQLQuery {
  From("posts")
  Fields("id", "title")
}

Nested queries can be defined in their logical order now:

let query = GraphQLQuery {
  From("posts")
  Fields("id", "title")
  SubQuery {
    From("comments")
    Fields("body")
    SubQuery {
      From("author")
      Fields("firstname")
    }
  }
}

Known Issues

  • Queries with multiple root fields and arguments produce a compiler error (e.g. 'Int' is not convertible to 'Any')

Usage

Chester uses the builder pattern to construct GraphQL queries. In its basic form use it like this:

import Chester

let query = QueryBuilder()
  .from("posts")
  .with(arguments: Argument(key: "id", value: "20"), Argument(key: "author", value: "Chester"))
  .with(fields: "id", "title", "content")

// For cases with dynamic input, probably best to use a do-catch:

do {
  let queryString = try query.build
} catch {
  // Can specify which errors to catch
}

// Or if you're sure of your query

guard let queryString = try? query.build else { return }

You can add subqueries. Add as many as needed. You can nest them as well.

let commentsQuery = QueryBuilder()
  .from("comments")
  .with(fields: "id", content)
let postsQuery = QueryBuilder()
  .from("posts")
  .with(fields: "id", "title")
  .with(subQuery: commentsQuery)

You can search on multiple collections at once

let search = QueryBuilder()
  .from("search")
  .with(arguments: Argument(key: "text", value: "an"))
  .on("Human", "Droid")
  .with(fields: "name")
  .build()

Check the included unit tests for further examples.

Requirements

  • Swift 5
  • Xcode 10.2+
  • iOS 8

Installation

Chester is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Chester"

Or Carthage. Add Chester to your Cartfile:

github "JanGorman/Chester"

Author

Jan Gorman

License

Chester is available under the MIT license. See the LICENSE file for more info.

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