Skip to content

Commit

Permalink
refactor: graphql layer (#3017)
Browse files Browse the repository at this point in the history
* chore: refactoring graphql layer.

clearing outlying what is shared and what is not

* chore: remove unused

---------

Co-authored-by: Nicolas Burtey <[email protected]>
  • Loading branch information
nicolasburtey and Nicolas Burtey authored Aug 8, 2023
1 parent 87cf0d5 commit 917b797
Show file tree
Hide file tree
Showing 234 changed files with 573 additions and 592 deletions.
2 changes: 1 addition & 1 deletion .github/graphql-inspector.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
branch: main
schema: src/graphql/main/schema.graphql
schema: src/graphql/public/schema.graphql
2 changes: 1 addition & 1 deletion .github/workflows/graphql-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
- uses: actions/checkout@v3
- uses: kamilkisiela/graphql-inspector@master
with:
schema: "main:src/graphql/main/schema.graphql"
schema: "main:src/graphql/public/schema.graphql"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ For an overview of all relevant repository checkout [awesome-galoy](https://gith

- GraphqlAPI:
- Public API following industry best practices
- For [end clients](./src/graphql/main/schema.graphql). [Documentation](https://galoymoney.github.io/galoy/)
- For [end clients](./src/graphql/public/schema.graphql). [Documentation](https://galoymoney.github.io/galoy/)
- For [admin activities](./src/graphql/admin/schema.graphql)
- Authentication:
- Code is sent via twillio to end users phone number which can be exchanged for jwt auth token
Expand Down
4 changes: 2 additions & 2 deletions ci/tasks/check-mobile-schema-compatibility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
curl -fsS https://raw.githubusercontent.com/GaloyMoney/galoy-mobile/main/app/graphql/generated.gql -o main.gql

echo Checking compatibility with current main branch of galoy-mobile
npx @graphql-inspector/cli validate ./main.gql repo/src/graphql/main/schema.graphql --apollo --noStrictFragments
npx @graphql-inspector/cli validate ./main.gql repo/src/graphql/public/schema.graphql --apollo --noStrictFragments

for file in mobile-deployments/deployed-schemas/*
do
filename=$(basename "$file")
echo Checking compatibility with ${filename%.*}
npx @graphql-inspector/cli validate $file repo/src/graphql/main/schema.graphql --apollo --noStrictFragments
npx @graphql-inspector/cli validate $file repo/src/graphql/public/schema.graphql --apollo --noStrictFragments
done
2 changes: 1 addition & 1 deletion dev/apollo-federation/supergraph-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ subgraphs:
public:
routing_url: http://bats-tests:4012/graphql
schema:
file: ../../src/graphql/main/schema.graphql
file: ../../src/graphql/public/schema.graphql
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"eslint-fix": "eslint \"{src,test}/**/*.ts\" --fix",
"build": "tsc -p tsconfig-build.json && cp -R src/services/price/protos lib/services/price/ && cp -R src/services/dealer-price/proto lib/services/dealer-price/ && cp -R src/services/loopd/protos lib/services/loopd/ && cp -R src/services/bria/proto lib/services/bria/ && tscpaths --silent -p tsconfig.json -s ./src -o ./lib",
"trigger": "yarn build && node lib/servers/trigger.js | pino-pretty -c -l",
"check:sdl": "yarn write-sdl && if git diff --name-only | grep -q 'src/graphql/admin/schema.graphql'; then echo 'Error: src/graphql/admin/schema.graphql has changes, run `make codegen` and re-recommit' >&2; exit 1; fi && if git diff --name-only | grep -q 'src/graphql/main/schema.graphql'; then echo 'Error: src/graphql/main/schema.graphql has changes, run `make codegen` and re-recommit' >&2; exit 1; fi",
"check:sdl": "yarn write-sdl && if git diff --name-only | grep -q 'src/graphql/admin/schema.graphql'; then echo 'Error: src/graphql/admin/schema.graphql has changes, run `make codegen` and re-recommit' >&2; exit 1; fi && if git diff --name-only | grep -q 'src/graphql/public/schema.graphql'; then echo 'Error: src/graphql/public/schema.graphql has changes, run `make codegen` and re-recommit' >&2; exit 1; fi",
"write-sdl": "yarn build && node lib/servers/write-sdl.js write-sdl.yaml && rover supergraph compose --config dev/apollo-federation/supergraph-config.yaml --elv2-license accept > dev/apollo-federation/supergraph.graphql",
"ws": "yarn build && node lib/servers/ws-server.js | pino-pretty -c -l",
"watch": "nodemon -V -e ts,graphql -w ./src -x yarn run start",
"watch-trigger": "nodemon -V -e ts,graphql -w ./src -x yarn trigger",
"graphql-check": "curl -fsS https://raw.githubusercontent.com/GaloyMoney/galoy-mobile/main/app/graphql/generated.gql -o generated.gql && npx @graphql-inspector/cli validate ./generated.gql src/graphql/main/schema.graphql --apollo --noStrictFragments",
"graphql-check": "curl -fsS https://raw.githubusercontent.com/GaloyMoney/galoy-mobile/main/app/graphql/generated.gql -o generated.gql && npx @graphql-inspector/cli validate ./generated.gql src/graphql/public/schema.graphql --apollo --noStrictFragments",
"cron": ". ./.envrc && yarn build && node lib/servers/cron.js",
"exporter": "yarn build && node lib/servers/exporter.js",
"daily-notif": "yarn build && node lib/servers/daily-balance-notification.js",
Expand Down
2 changes: 1 addition & 1 deletion spectaql/spectaql-config-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ spectaql:
logoFile: ./public/logo.png

introspection:
schemaFile: ./src/graphql/main/schema.graphql
schemaFile: ./src/graphql/public/schema.graphql

info:
title: GraphQL API Reference
Expand Down
2 changes: 1 addition & 1 deletion src/debug/websocket/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"ws": "yarn build && node lib/servers/ws-server.js | pino-pretty -c -l",
"watch": "nodemon -V -e ts,graphql -w ./src -x yarn run start",
"watch-trigger": "nodemon -V -e ts,graphql -w ./src -x yarn trigger",
"graphql-check": "curl -fsS https://raw.githubusercontent.com/GaloyMoney/galoy-mobile/main/app/graphql/generated.gql -o generated.gql && npx @graphql-inspector/cli validate ./generated.gql src/graphql/main/schema.graphql --apollo --noStrictFragments",
"graphql-check": "curl -fsS https://raw.githubusercontent.com/GaloyMoney/galoy-mobile/main/app/graphql/generated.gql -o generated.gql && npx @graphql-inspector/cli validate ./generated.gql src/graphql/public/schema.graphql --apollo --noStrictFragments",
"cron": ". ./.envrc && yarn build && node lib/servers/cron.js",
"exporter": "yarn build && node lib/servers/exporter.js",
"daily-notif": "yarn build && node lib/servers/daily-balance-notification.js",
Expand Down
8 changes: 4 additions & 4 deletions src/graphql/admin/mutations.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { GT } from "@graphql/index"

import UserRequestAuthCodeMutation from "@graphql/root/mutation/user-request-auth-code"
import UserLoginMutation from "@graphql/root/mutation/user-login"
import CaptchaRequestAuthCodeMutation from "@graphql/root/mutation/captcha-request-auth-code"
import CaptchaCreateChallengeMutation from "@graphql/root/mutation/captcha-create-challenge"
import UserRequestAuthCodeMutation from "@graphql/shared/root/mutation/user-request-auth-code"
import UserLoginMutation from "@graphql/shared/root/mutation/user-login"
import CaptchaRequestAuthCodeMutation from "@graphql/shared/root/mutation/captcha-request-auth-code"
import CaptchaCreateChallengeMutation from "@graphql/shared/root/mutation/captcha-create-challenge"

import AccountUpdateLevelMutation from "@graphql/admin/root/mutation/account-update-level"
import AccountUpdateStatusMutation from "@graphql/admin/root/mutation/account-update-status"
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/admin/root/mutation/account-update-level.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Accounts } from "@app"
import AccountDetailPayload from "@graphql/admin/types/payload/account-detail"
import AccountLevel from "@graphql/types/scalar/account-level"
import AccountLevel from "@graphql/shared/types/scalar/account-level"
import { mapAndParseErrorForGqlResponse } from "@graphql/error-map"
import { GT } from "@graphql/index"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Accounts } from "@app"
import AccountDetailPayload from "@graphql/admin/types/payload/account-detail"
import { mapAndParseErrorForGqlResponse } from "@graphql/error-map"
import { GT } from "@graphql/index"
import Username from "@graphql/types/scalar/username"
import Username from "@graphql/shared/types/scalar/username"

const BusinessUpdateMapInfoInput = GT.Input({
name: "BusinessUpdateMapInfoInput",
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/admin/root/mutation/delete-business-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Accounts } from "@app"
import AccountDetailPayload from "@graphql/admin/types/payload/account-detail"
import { mapAndParseErrorForGqlResponse } from "@graphql/error-map"
import { GT } from "@graphql/index"
import Username from "@graphql/types/scalar/username"
import Username from "@graphql/shared/types/scalar/username"

const BusinessDeleteMapInfoInput = GT.Input({
name: "BusinessDeleteMapInfoInput",
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/admin/root/mutation/user-update-phone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GT } from "@graphql/index"
import AccountDetailPayload from "@graphql/admin/types/payload/account-detail"
import { Admin } from "@app"
import { mapAndParseErrorForGqlResponse } from "@graphql/error-map"
import Phone from "@graphql/types/scalar/phone"
import Phone from "@graphql/shared/types/scalar/phone"

const UserUpdatePhoneInput = GT.Input({
name: "UserUpdatePhoneInput",
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/admin/root/query/account-details-by-email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import GraphQLAccount from "@graphql/admin/types/object/account"
import { mapError } from "@graphql/error-map"

import { Admin } from "@app"
import EmailAddress from "@graphql/types/scalar/email-address"
import EmailAddress from "@graphql/shared/types/scalar/email-address"

const AccountDetailsByUserEmailQuery = GT.Field<{
// FIXME: doesn't respect the input: {} pattern
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/admin/root/query/account-details-by-phone.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GT } from "@graphql/index"

import GraphQLAccount from "@graphql/admin/types/object/account"
import Phone from "@graphql/types/scalar/phone"
import Phone from "@graphql/shared/types/scalar/phone"
import { mapError } from "@graphql/error-map"

import { Admin } from "@app"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GT } from "@graphql/index"

import GraphQLAccount from "@graphql/admin/types/object/account"
import Username from "@graphql/types/scalar/username"
import Username from "@graphql/shared/types/scalar/username"
import { mapError } from "@graphql/error-map"

import { Admin } from "@app"
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/admin/root/query/all-levels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { GT } from "@graphql/index"

import { Levels } from "@config"

import AccountLevel from "@graphql/types/scalar/account-level"
import AccountLevel from "@graphql/shared/types/scalar/account-level"

const AllLevelsQuery = GT.Field({
type: GT.NonNullList(AccountLevel),
Expand Down
4 changes: 2 additions & 2 deletions src/graphql/admin/root/query/all-walletids.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GT } from "@graphql/index"
import { Wallets } from "@app"
import WalletCurrency from "@graphql/types/scalar/wallet-currency"
import WalletId from "@graphql/types/scalar/wallet-id"
import WalletCurrency from "@graphql/shared/types/scalar/wallet-currency"
import WalletId from "@graphql/shared/types/scalar/wallet-id"

const ListWalletIdsQuery = GT.Field({
type: GT.NonNullList(WalletId),
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/admin/root/query/lightning-invoice.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GT } from "@graphql/index"
import { Lightning } from "@app"
import PaymentHash from "@graphql/types/scalar/payment-hash"
import PaymentHash from "@graphql/shared/types/scalar/payment-hash"
import LightningInvoice from "@graphql/admin/types/object/lightning-invoice"
import { mapError } from "@graphql/error-map"

Expand Down
2 changes: 1 addition & 1 deletion src/graphql/admin/root/query/lightning-payment.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GT } from "@graphql/index"
import { Lightning } from "@app"
import PaymentHash from "@graphql/types/scalar/payment-hash"
import PaymentHash from "@graphql/shared/types/scalar/payment-hash"
import LightningPayment from "@graphql/admin/types/object/lightning-payment"
import { mapError } from "@graphql/error-map"
import { LnPaymentsRepository } from "@services/mongoose"
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/admin/root/query/transaction-by-id.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GT } from "@graphql/index"

import { Wallets } from "@app"
import Transaction from "@graphql/types/object/transaction"
import Transaction from "@graphql/shared/types/object/transaction"
import { mapError } from "@graphql/error-map"

const TransactionByIdQuery = GT.Field({
Expand Down
4 changes: 2 additions & 2 deletions src/graphql/admin/root/query/transactions-by-hash.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { GT } from "@graphql/index"

import { Wallets } from "@app"
import Transaction from "@graphql/types/object/transaction"
import PaymentHash from "@graphql/types/scalar/payment-hash"
import Transaction from "@graphql/shared/types/object/transaction"
import PaymentHash from "@graphql/shared/types/scalar/payment-hash"
import { mapError } from "@graphql/error-map"

const TransactionsByHashQuery = GT.Field({
Expand Down
4 changes: 2 additions & 2 deletions src/graphql/admin/root/query/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Wallets } from "@app"
import { GT } from "@graphql/index"
import IWallet from "@graphql/types/abstract/wallet"
import WalletId from "@graphql/types/scalar/wallet-id"
import IWallet from "@graphql/shared/types/abstract/wallet"
import WalletId from "@graphql/shared/types/scalar/wallet-id"

const WalletQuery = GT.Field({
type: GT.NonNull(IWallet),
Expand Down
6 changes: 3 additions & 3 deletions src/graphql/admin/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BtcWallet from "@graphql/types/object/btc-wallet"
import GraphQLApplicationError from "@graphql/types/object/graphql-application-error"
import UsdWallet from "@graphql/types/object/usd-wallet"
import BtcWallet from "@graphql/shared/types/object/btc-wallet"
import GraphQLApplicationError from "@graphql/shared/types/object/graphql-application-error"
import UsdWallet from "@graphql/shared/types/object/usd-wallet"

export const ALL_INTERFACE_TYPES = [GraphQLApplicationError, BtcWallet, UsdWallet]
11 changes: 6 additions & 5 deletions src/graphql/admin/types/object/account.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Wallets, Users } from "@app"
import { GT } from "@graphql/index"
import Coordinates from "@graphql/types/object/coordinates"
import Timestamp from "@graphql/types/scalar/timestamp"
import Username from "@graphql/types/scalar/username"
import Coordinates from "@graphql/shared/types/object/coordinates"
import Timestamp from "@graphql/shared/types/scalar/timestamp"
import Username from "@graphql/shared/types/scalar/username"
import { GraphQLObjectType } from "graphql"
import Wallet from "@graphql/types/abstract/wallet"
import Wallet from "@graphql/shared/types/abstract/wallet"
import { mapError } from "@graphql/error-map"

import AccountLevel from "../../../types/scalar/account-level"
import AccountLevel from "@graphql/shared/types/scalar/account-level"

import AccountStatus from "../scalar/account-status"

import GraphQLUser from "./user"
Expand Down
8 changes: 4 additions & 4 deletions src/graphql/admin/types/object/lightning-invoice.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { GT } from "@graphql/index"
import LnPaymentPreImage from "@graphql/types/scalar/ln-payment-preimage"
import LnPaymentRequest from "@graphql/types/scalar/ln-payment-request"
import SatAmount from "@graphql/types/scalar/sat-amount"
import Timestamp from "@graphql/types/scalar/timestamp"
import LnPaymentPreImage from "@graphql/shared/types/scalar/ln-payment-preimage"
import LnPaymentRequest from "@graphql/shared/types/scalar/ln-payment-request"
import SatAmount from "@graphql/shared/types/scalar/sat-amount"
import Timestamp from "@graphql/shared/types/scalar/timestamp"

const LightningInvoice = GT.Object<LnInvoiceLookup>({
name: "LightningInvoice",
Expand Down
12 changes: 6 additions & 6 deletions src/graphql/admin/types/object/lightning-payment.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { GT } from "@graphql/index"
import LnPubkey from "@graphql/types/scalar/ln-pubkey"
import Timestamp from "@graphql/types/scalar/timestamp"
import SatAmount from "@graphql/types/scalar/sat-amount"
import LnPaymentStatus from "@graphql/types/scalar/ln-payment-status"
import LnPaymentRequest from "@graphql/types/scalar/ln-payment-request"
import LnPaymentPreImage from "@graphql/types/scalar/ln-payment-preimage"
import LnPubkey from "@graphql/shared/types/scalar/ln-pubkey"
import Timestamp from "@graphql/shared/types/scalar/timestamp"
import SatAmount from "@graphql/shared/types/scalar/sat-amount"
import LnPaymentStatus from "@graphql/shared/types/scalar/ln-payment-status"
import LnPaymentRequest from "@graphql/shared/types/scalar/ln-payment-request"
import LnPaymentPreImage from "@graphql/shared/types/scalar/ln-payment-preimage"

const LightningPayment = GT.Object<LnPaymentLookup>({
name: "LightningPayment",
Expand Down
12 changes: 0 additions & 12 deletions src/graphql/admin/types/object/psbt-detail.ts

This file was deleted.

8 changes: 4 additions & 4 deletions src/graphql/admin/types/object/user.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { mapError } from "@graphql/error-map"
import { GT } from "@graphql/index"
import GraphQLEmail from "@graphql/types/object/email"
import Language from "@graphql/types/scalar/language"
import Phone from "@graphql/types/scalar/phone"
import Timestamp from "@graphql/types/scalar/timestamp"
import GraphQLEmail from "@graphql/shared/types/object/email"
import Language from "@graphql/shared/types/scalar/language"
import Phone from "@graphql/shared/types/scalar/phone"
import Timestamp from "@graphql/shared/types/scalar/timestamp"

// FIXME should not use service
import { IdentityRepository } from "@services/kratos"
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/admin/types/payload/account-detail.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GT } from "@graphql/index"
import IError from "@graphql/types/abstract/error"
import IError from "@graphql/shared/types/abstract/error"

import GraphQLAccount from "../object/account"

Expand Down
17 changes: 0 additions & 17 deletions src/graphql/admin/types/payload/psbt-detail.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/graphql/admin/types/payload/wallet-details.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GT } from "@graphql/index"
import IError from "@graphql/types/abstract/error"
import Wallet from "@graphql/types/abstract/wallet"
import IError from "@graphql/shared/types/abstract/error"
import Wallet from "@graphql/shared/types/abstract/wallet"

const WalletDetailsPayload = GT.Object({
name: "WalletDetailsPayload",
Expand Down
Loading

0 comments on commit 917b797

Please sign in to comment.