Skip to content

Commit

Permalink
reduce duplicate types
Browse files Browse the repository at this point in the history
  • Loading branch information
roneli committed Mar 14, 2024
1 parent 78e4076 commit 381973a
Show file tree
Hide file tree
Showing 92 changed files with 3,937 additions and 3,959 deletions.
12 changes: 6 additions & 6 deletions .gitbook.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
root: ./docs/

structure:
readme: ./base.md
summary: ./SUMMARY.md

root: ./docs/

structure:
readme: ./base.md
summary: ./SUMMARY.md

22 changes: 11 additions & 11 deletions .github/workflows/check-generate.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash

set -euo pipefail

go generate ./...

if [[ $(git --no-pager diff) ]] ; then
echo "you need to run "go generate ./..." and commit the changes"
git --no-pager diff
exit 1
fi
#!/bin/bash

set -euo pipefail

go generate ./...

if [[ $(git --no-pager diff) ]] ; then
echo "you need to run "go generate ./..." and commit the changes"
git --no-pager diff
exit 1
fi
40 changes: 20 additions & 20 deletions .github/workflows/check-init
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#!/bin/bash

set -euo pipefail

fastgql_dir=$(pwd)
cd $(mktemp -d)
go mod init inittest
printf '// +build tools\npackage tools\nimport _ "github.com/roneli/fastgql"' | gofmt > tools.go
go mod tidy
go mod edit -replace=github.com/roneli/fastgql="$fastgql_dir"
go mod tidy

if ! go run github.com/roneli/fastgql init ; then
echo "gqlgen init failed"
exit 125
fi

if ! go run github.com/roneli/fastgql generate -c gqlgen.yml ; then
echo "gqlgen generate failed"
exit 125
#!/bin/bash

set -euo pipefail

fastgql_dir=$(pwd)
cd $(mktemp -d)
go mod init inittest
printf '// +build tools\npackage tools\nimport _ "github.com/roneli/fastgql"' | gofmt > tools.go
go mod tidy
go mod edit -replace=github.com/roneli/fastgql="$fastgql_dir"
go mod tidy

if ! go run github.com/roneli/fastgql init ; then
echo "gqlgen init failed"
exit 125
fi

if ! go run github.com/roneli/fastgql generate -c gqlgen.yml ; then
echo "gqlgen generate failed"
exit 125
fi
10 changes: 5 additions & 5 deletions .github/workflows/data/.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
POSTGRES_PASSWORD=
POSTGRES_USER=postgres
POSTGRES_HOST=postgres
POSTGRES_DB=postgres
POSTGRES_HOST_AUTH_METHOD=trust
POSTGRES_PASSWORD=
POSTGRES_USER=postgres
POSTGRES_HOST=postgres
POSTGRES_DB=postgres
POSTGRES_HOST_AUTH_METHOD=trust
20 changes: 10 additions & 10 deletions .github/workflows/data/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version: '3.1'
services:
db:
image: postgres
restart: always
env_file:
- .env
volumes:
- ./:/docker-entrypoint-initdb.d
ports:
version: '3.1'
services:
db:
image: postgres
restart: always
env_file:
- .env
volumes:
- ./:/docker-entrypoint-initdb.d
ports:
- 5432:5432
156 changes: 78 additions & 78 deletions .github/workflows/data/init.sql
Original file line number Diff line number Diff line change
@@ -1,78 +1,78 @@
-- create schema for example/interface/schema.graphql

CREATE TABLE animals (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
type TEXT NOT NULL,
breed TEXT NOT NULL,
color TEXT NOT NULL
);

CREATE TABLE "user" (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE post (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
user_id INTEGER NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE category (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE posts_to_categories (
post_id INTEGER NOT NULL,
category_id INTEGER NOT NULL,
PRIMARY KEY (post_id, category_id)
);

-- initialize base data
INSERT INTO "user" (name) VALUES ('Alice');
INSERT INTO "user" (name) VALUES ('Bob');
INSERT INTO "user" (name) VALUES ('Charlie');
INSERT INTO "user" (name) VALUES ('David');
INSERT INTO "user" (name) VALUES ('Eve');

INSERT INTO category (name) VALUES ('News');
INSERT INTO category (name) VALUES ('Technology');
INSERT INTO category (name) VALUES ('Science');
INSERT INTO category (name) VALUES ('Sports');
INSERT INTO category (name) VALUES ('Entertainment');

INSERT INTO post (name, user_id) VALUES ('Hello World', 1);
INSERT INTO post (name, user_id) VALUES ('GraphQL is awesome', 2);
INSERT INTO post (name, user_id) VALUES ('Postgres is cool', 3);
INSERT INTO post (name, user_id) VALUES ('Deno is interesting', 4);
INSERT INTO post (name, user_id) VALUES ('Node.js is fast', 5);

-- some posts are in multiple categories
INSERT INTO posts_to_categories (post_id, category_id) VALUES (1, 1);
INSERT INTO posts_to_categories (post_id, category_id) VALUES (2, 2);
INSERT INTO posts_to_categories (post_id, category_id) VALUES (3, 3);
INSERT INTO posts_to_categories (post_id, category_id) VALUES (4, 4);
INSERT INTO posts_to_categories (post_id, category_id) VALUES (5, 5);
INSERT INTO posts_to_categories (post_id, category_id) VALUES (1, 2);
INSERT INTO posts_to_categories (post_id, category_id) VALUES (2, 3);
INSERT INTO posts_to_categories (post_id, category_id) VALUES (3, 4);
INSERT INTO posts_to_categories (post_id, category_id) VALUES (4, 5);
INSERT INTO posts_to_categories (post_id, category_id) VALUES (5, 1);


-- insert some animals
INSERT INTO animals (name, type, breed, color) VALUES ('Fido', 'dog', 'labrador', 'black');
INSERT INTO animals (name, type, breed, color) VALUES ('Whiskers', 'cat', 'siamese', 'white');
INSERT INTO animals (name, type, breed, color) VALUES ('Spot', 'dog', 'dalmatian', 'white');
INSERT INTO animals (name, type, breed, color) VALUES ('Fluffy', 'cat', 'persian', 'grey');
INSERT INTO animals (name, type, breed, color) VALUES ('Rover', 'dog', 'bulldog', 'brown');
INSERT INTO animals (name, type, breed, color) VALUES ('Mittens', 'cat', 'maine coon', 'black');

-- create schema for example/interface/schema.graphql

CREATE TABLE animals (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
type TEXT NOT NULL,
breed TEXT NOT NULL,
color TEXT NOT NULL
);

CREATE TABLE "user" (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE post (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
user_id INTEGER NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE category (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE posts_to_categories (
post_id INTEGER NOT NULL,
category_id INTEGER NOT NULL,
PRIMARY KEY (post_id, category_id)
);

-- initialize base data
INSERT INTO "user" (name) VALUES ('Alice');
INSERT INTO "user" (name) VALUES ('Bob');
INSERT INTO "user" (name) VALUES ('Charlie');
INSERT INTO "user" (name) VALUES ('David');
INSERT INTO "user" (name) VALUES ('Eve');

INSERT INTO category (name) VALUES ('News');
INSERT INTO category (name) VALUES ('Technology');
INSERT INTO category (name) VALUES ('Science');
INSERT INTO category (name) VALUES ('Sports');
INSERT INTO category (name) VALUES ('Entertainment');

INSERT INTO post (name, user_id) VALUES ('Hello World', 1);
INSERT INTO post (name, user_id) VALUES ('GraphQL is awesome', 2);
INSERT INTO post (name, user_id) VALUES ('Postgres is cool', 3);
INSERT INTO post (name, user_id) VALUES ('Deno is interesting', 4);
INSERT INTO post (name, user_id) VALUES ('Node.js is fast', 5);

-- some posts are in multiple categories
INSERT INTO posts_to_categories (post_id, category_id) VALUES (1, 1);
INSERT INTO posts_to_categories (post_id, category_id) VALUES (2, 2);
INSERT INTO posts_to_categories (post_id, category_id) VALUES (3, 3);
INSERT INTO posts_to_categories (post_id, category_id) VALUES (4, 4);
INSERT INTO posts_to_categories (post_id, category_id) VALUES (5, 5);
INSERT INTO posts_to_categories (post_id, category_id) VALUES (1, 2);
INSERT INTO posts_to_categories (post_id, category_id) VALUES (2, 3);
INSERT INTO posts_to_categories (post_id, category_id) VALUES (3, 4);
INSERT INTO posts_to_categories (post_id, category_id) VALUES (4, 5);
INSERT INTO posts_to_categories (post_id, category_id) VALUES (5, 1);


-- insert some animals
INSERT INTO animals (name, type, breed, color) VALUES ('Fido', 'dog', 'labrador', 'black');
INSERT INTO animals (name, type, breed, color) VALUES ('Whiskers', 'cat', 'siamese', 'white');
INSERT INTO animals (name, type, breed, color) VALUES ('Spot', 'dog', 'dalmatian', 'white');
INSERT INTO animals (name, type, breed, color) VALUES ('Fluffy', 'cat', 'persian', 'grey');
INSERT INTO animals (name, type, breed, color) VALUES ('Rover', 'dog', 'bulldog', 'brown');
INSERT INTO animals (name, type, breed, color) VALUES ('Mittens', 'cat', 'maine coon', 'black');

76 changes: 38 additions & 38 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
name: deploy Github pages

on:
# Trigger the workflow every time you push to the `main` branch
# Using a different branch name? Replace `main` with your branch’s name
push:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab on GitHub.
workflow_dispatch:

# Allow this job to clone the repo and create a page deployment
permissions:
contents: read
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout your repository using git
uses: actions/checkout@v3
- name: Install, build, and upload your site
uses: withastro/action@v1
with:
path: ./docs # The root location of your Astro project inside the repository. (optional)
# node-version: 18 # The specific version of Node that should be used to build your site. Defaults to 18. (optional)
package-manager: pnpm@latest # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional)

deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
name: deploy Github pages

on:
# Trigger the workflow every time you push to the `main` branch
# Using a different branch name? Replace `main` with your branch’s name
push:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab on GitHub.
workflow_dispatch:

# Allow this job to clone the repo and create a page deployment
permissions:
contents: read
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout your repository using git
uses: actions/checkout@v3
- name: Install, build, and upload your site
uses: withastro/action@v1
with:
path: ./docs # The root location of your Astro project inside the repository. (optional)
# node-version: 18 # The specific version of Node that should be used to build your site. Defaults to 18. (optional)
package-manager: pnpm@latest # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional)

deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
44 changes: 22 additions & 22 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
name: integration
on: [ pull_request ]
# When a new revision is pushed to a PR, cancel all in-progress CI runs for that
# PR. See https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
init:
strategy:
matrix:
go: [ "1.18", "1.20" ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- run: |
chmod +x .github/workflows/check-init
.github/workflows/check-init
name: integration
on: [ pull_request ]
# When a new revision is pushed to a PR, cancel all in-progress CI runs for that
# PR. See https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
init:
strategy:
matrix:
go: [ "1.18", "1.20" ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- run: |
chmod +x .github/workflows/check-init
.github/workflows/check-init
Loading

0 comments on commit 381973a

Please sign in to comment.