Skip to content

Commit

Permalink
perf(client): SwiftGraphQL 3.0.0 (#70)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: This PR improves query building logic and introduces a new full-blown GraphQL client.
  • Loading branch information
maticzav authored Aug 3, 2022
1 parent 4691b83 commit 0821319
Show file tree
Hide file tree
Showing 274 changed files with 188,725 additions and 5,797 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/generate:toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ on:

jobs:
build:
runs-on: macOS-latest
runs-on: ubuntu-latest

steps:
# Setup
- uses: actions/checkout@master
- uses: actions/setup-node@v1
with:
node-version: '13.x'
node-version-file: '.nvmrc'
cache: 'yarn'

# Build
- run: yarn install --skip-builds
- name: Generate table of contents

# Generate TOC
- name: Generate Table of Contents
run: ./scripts/toc.sh
27 changes: 27 additions & 0 deletions .github/workflows/migrate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Migrate TheSocialNetwork Database

on:
push:
branches:
- main

jobs:
migrate:
runs-on: ubuntu-latest
steps:
- name: Checkout Main
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node
uses: actions/setup-node@v2
with:
node-version: '16.x'

- name: Install dependencies
run: yarn workspaces focus tsn-server

- name: Deploy Migration
run: yarn workspace tsn-server deploy
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
name: Create a GitHub release
name: Create GitHub Release

on:
push:
branches:
- main
- next
paths:
- 'Sources/**/*'

jobs:
build:
runs-on: macOS-latest
runs-on: macos-12

steps:
- uses: actions/checkout@v2
# Test
- name: Perform unit tests.
run: |
swift package resolve
swift build
swift test
- name: Tests integrations from examples.
run: ./scripts/test.sh

# Release
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
# Relevant Branches
release_branches: main
pre_release_branches: next
# Tag configuration
tag_prefix: ''
default_bump: false
default_bump: 'patch'
# Credentials
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Create a GitHub release
uses: actions/create-release@v1
env:
Expand All @@ -40,3 +35,17 @@ jobs:
tag_name: ${{ steps.tag_version.outputs.new_tag }}
release_name: SwiftGraphQL ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
if: steps.tag_version.outputs.new_tag != null

- name: Create Release
run: |
make update_brew_formula
make update_podspec
git add .
git commit -m "Update Formula and PodSpec to $(VERSION)"
git push origin main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.tag_version.outputs.new_version }}
if: steps.tag_version.outputs.new_tag != null
17 changes: 0 additions & 17 deletions .github/workflows/publish:brew.yml

This file was deleted.

37 changes: 29 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
name: Test
name: Test Packages

on:
push: {}
pull_request: {}

jobs:
build:
runs-on: macOS-latest
test:
name: Test Sources

runs-on: macos-12

timeout-minutes: 30

steps:
- uses: actions/checkout@v2
- name: Resolve

# Build the Library
- name: Swift Resolve
run: swift package resolve
- name: Build
- name: Swift Build
run: swift build
- name: Perform package tests

# Start Test Server
- name: Use Node
uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install Server Dependencies
run: yarn install
- name: Start Test Server
run: yarn workspace server start &
- name: Wait for Server to Start
run: |
sleep 5
# Perform Tests
- name: Test Package
run: swift test
- name: Integration tests with workflows
run: ./scripts/test.sh
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
*.log*
.env*

# Swift

Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.13.0
31 changes: 31 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug swift-graphql",
"program": ".build/debug/swift-graphql",
"args": [],
"cwd": "${workspaceFolder:swift-graphql}",
"preLaunchTask": "swift: Build Debug swift-graphql"
},
{
"type": "lldb",
"request": "launch",
"name": "Release swift-graphql",
"program": ".build/release/swift-graphql",
"args": [],
"cwd": "${workspaceFolder:swift-graphql}",
"preLaunchTask": "swift: Build Release swift-graphql"
},
{
"type": "lldb",
"request": "launch",
"name": "Test swift-graphql",
"program": "/Applications/Xcode.app/Contents/Developer/usr/bin/xctest",
"args": [".build/debug/swift-graphqlPackageTests.xctest"],
"cwd": "${workspaceFolder:swift-graphql}",
"preLaunchTask": "swift: Build All"
}
]
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"editor.formatOnSave": true,
"editor.wordWrap": "on"
"editor.wordWrap": "on",
"lldb.library": "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB"
}
55 changes: 55 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Contributing to SwiftGraphQL

Hey :wave:! This library is a collaborative effort of many people and we are all very excited to see you here. This file will help you navigate around more easily and make sure your pull requests receive attention they deserve.

This package is best developed using Swift command line tools.

> NOTE: SwiftGraphQL depends on `swift-format` that relies on `SwiftSyntax` that is distributed as part of the Swift toolchain. It's important that you set the correct version of Swift Command Line Tools when developing so that the tools match the version of `swift-format` used.
```sh
swift package tools-version --set 5.5
```

## Code Organization

SwiftGraphQL is split into multiple packages that serve different purposes.

1. **GraphQL** contains the structures that appear in all GraphQL requests,
1. **GraphQLAST** describes the models and methods used for fetching information about the schema,
1. **GraphQLWebSocket** implements a [GraphQL over WebSocket protocol](https://github.com/enisdenjo/graphql-ws),
1. **SwiftGraphQL** is a query builder library,
1. **SwiftGraphQLCodegen** generates methods that you may use to build type-safe queries,
1. **SwiftGraphQLCLI** exposes a ready to use CLI tool for code generation.

## Roadmap

Feel free to contribute in any way possible. We are excited about your ideas and want to share them with the rest of the world. It's often even more helpful to write a well documented idea than to write code because ["code is the easy part"](https://www.youtube.com/watch?v=DSjbTC-hvqQ).

We are currently investing our efforts into

- Swift Docc Reference of the library,
- Normalized Caching exchange,
- Subscriptions over SSE exchange,
- SwiftUI bindings

Contributing in any of these topics will get a lot of attention and have top priority.

> If you have any questions about the library, feel free to reach out to Matic at `matic.zavadlal [at] gmail.com`.
## Creating a Pull Request

> Every PR should follow a common structure. This way, it's easier for people to navigate the code, look back at the PRs and understand why library has evolved the way it has.
Every PR should follow the next set of guidelines

1. Title should be well-formated (e.g. "Add WebSocket Support for Apple Watch", not "add WS for apple watch").
1. The first comment should clearly outline what you've changed and, if necessary, why.
1. Make sure that comments in the PR and in the code are grammatically correct.
1. Check _all_ your changes in GitHub files tab before _again_ before requesting a review.
1. Suggest a release type (e.g. patch, minor, major) for your change.

## Building Binary and Documentation

```sh
swift build -c release --product swift-graphql --disable-sandbox
```
21 changes: 0 additions & 21 deletions Dockerfile

This file was deleted.

14 changes: 10 additions & 4 deletions Formula/SwiftGraphQL.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
class Swiftgraphql < Formula
desc "GraphQL code generator and client written in Swift"
homepage "https://github.com/maticzav/SwiftGraphQL"
class SwiftGraphQL < Formula
desc "Code generator for SwiftGraphQL library"
homepage "https://swift-graphql.org"
license "MIT"

url "https://github.com/maticzav/swift-graphql/archive/2.3.0.tar.gz"
sha256 "4f2d22e03ca65ce9b3f488bd48fb1b04b29c62f78d054e20e3d12c4f7a92aed8"
license "MIT"

head "https://github.com/maticzav/swift-graphql.git"

depends_on :xcode
Expand All @@ -13,4 +15,8 @@ class Swiftgraphql < Formula
def install
system "make", "install", "PREFIX=#{prefix}"
end

def test
system "true"
end
end
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
TOOL_NAME = swift-graphql
VERSION = $(shell git describe --abbrev=0 --tags)

PREFIX = /usr/local

INSTALL_PATH = $(PREFIX)/bin/$(TOOL_NAME)
SHARE_PATH = $(PREFIX)/share/$(TOOL_NAME)
BUILD_PATH = .build/release/$(TOOL_NAME)
CURRENT_PATH = $(PWD)
REPO = https://github.com/maticzav/$(TOOL_NAME)
RELEASE_TAR = $(REPO)/archive/$(VERSION).tar.gz
SHA = $(shell curl -L -s $(RELEASE_TAR) | shasum -a 256 | sed 's/ .*//')

# Commands

build:
swift build --disable-sandbox -c release
swift build --disable-sandbox -c release --product $(TOOL_NAME)

install: build
mkdir -p $(PREFIX)/bin
Expand All @@ -20,12 +19,13 @@ install: build
uninstall:
rm -f $(INSTALL_PATH)

format:
swiftformat .
REPO = https://github.com/maticzav/$(TOOL_NAME)
RELEASE_TAR = $(REPO)/archive/$(VERSION).tar.gz
SHA = $(shell curl -L -s $(RELEASE_TAR) | shasum -a 256 | sed 's/ .*//')

update_brew:
sed -i '' 's|\(url ".*/archive/\)\(.*\)\(.tar\)|\1$(VERSION)\3|' Formula/SwiftGraphQL.rb
sed -i '' 's|\(sha256 "\)\(.*\)\("\)|\1$(SHA)\3|' Formula/SwiftGraphQL.rb
update_podspec:
sed -i '' "s|\(version .* = '\)\(.*\)\('\)|\1$(VERSION)\3|" SwiftGraphQL.podspec

git add .
git commit -m "Update brew to $(VERSION)"
update_brew_formula:
sed -i '' 's|\(url ".*/archive/\)\(.*\)\(.tar\)|\1$(VERSION)\3|' Formula/swiftgraphql.rb
sed -i '' 's|\(sha256 "\)\(.*\)\("\)|\1$(SHA)\3|' Formula/swiftgraphql.rb
Loading

1 comment on commit 0821319

@vercel
Copy link

@vercel vercel bot commented on 0821319 Aug 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.