thdxr
03/16/2022, 8:58 PMAlex Ketchum
03/16/2022, 9:27 PMthdxr
03/16/2022, 9:28 PMAlex Ketchum
03/16/2022, 9:29 PMAlex Ketchum
03/16/2022, 9:30 PMthdxr
03/16/2022, 9:30 PMthdxr
03/16/2022, 9:31 PMhttps://github.com/babyfish-ct/graphql-ts-client/raw/master/graphql-ts-client.gif▾
thdxr
03/16/2022, 9:31 PMMichael Wolfenden
03/16/2022, 10:45 PMMichael Wolfenden
03/16/2022, 10:45 PMthdxr
03/16/2022, 10:51 PMRoberto Novelo
03/17/2022, 3:21 AMgraphql-codegen
to generate types for my packages into a package e.g.
overwrite: true
schema:
- <redacted>
- <redacted>/appsync.graphql
config:
scalars:
AWSJSON: string
AWSDate: string
AWSTime: string
AWSDateTime: string
AWSTimestamp: number
AWSEmail: string
AWSURL: string
AWSPhone: string
AWSIPAddress: string
generates:
<redacted>
plugins:
- typescript
I have my own schemas, and also a simple schema for Appsync types, e.g.
scalar AWSDate
scalar AWSTime
scalar AWSDateTime
scalar AWSTimestamp
scalar AWSEmail
scalar AWSJSON
scalar AWSURL
scalar AWSPhone
scalar AWSIPAddress
Roberto Novelo
03/17/2022, 3:22 AMtypes-package
Roberto Novelo
03/17/2022, 3:23 AMconst gql = _String_.raw;
. For the backend I always use the types though~.. Some of the UI is generated during runtime so I am using some JS in the stack for quick wins 🙂Omi Chowdhury
03/17/2022, 5:39 AMtypescript-operations
and `typescript-urql`:
schema: ../services/graphql/exports/introspection-result.json
documents: './src/**/*.query.ts'
generates:
src/hooks/internalApi.ts:
config:
withHooks: true
defaultScalarType: string
plugins:
- add:
content: "/* This file was generated by `yarn gen-graphql`. Don't edit it directly */ \n"
- typescript
- typescript-operations
- typescript-urql
hooks:
afterOneFileWrite:
- prettier --write
- eslint --fix
Seems to do what gql-tag-operations-preset
does, although I need to look more into doing fragments with this setup vs the preset. Hadn’t heard of it beforethdxr
03/17/2022, 10:54 AMGjorgji Kjosev
03/17/2022, 5:21 PMGjorgji Kjosev
03/17/2022, 5:22 PMthdxr
03/17/2022, 5:23 PMGjorgji Kjosev
03/17/2022, 5:24 PMthdxr
03/17/2022, 5:28 PMGjorgji Kjosev
03/17/2022, 5:46 PMGjorgji Kjosev
03/17/2022, 5:46 PMthdxr
03/17/2022, 6:03 PMGjorgji Kjosev
03/17/2022, 7:14 PMthdxr
03/17/2022, 7:15 PMGjorgji Kjosev
03/17/2022, 8:06 PMGjorgji Kjosev
03/17/2022, 8:07 PMGjorgji Kjosev
03/17/2022, 8:07 PMGjorgji Kjosev
03/17/2022, 8:09 PMGjorgji Kjosev
03/17/2022, 8:09 PMGjorgji Kjosev
03/17/2022, 8:14 PMGjorgji Kjosev
03/17/2022, 8:14 PMthdxr
03/17/2022, 8:17 PMthdxr
03/17/2022, 8:18 PMGjorgji Kjosev
03/17/2022, 8:25 PMGjorgji Kjosev
03/17/2022, 8:25 PMGjorgji Kjosev
03/17/2022, 8:25 PMthdxr
03/17/2022, 8:25 PMDamjan
03/17/2022, 8:27 PMGjorgji Kjosev
03/18/2022, 6:12 PMGjorgji Kjosev
03/18/2022, 6:12 PMthdxr
03/19/2022, 2:37 PMthdxr
03/19/2022, 2:38 PMGjorgji Kjosev
03/19/2022, 5:21 PMGjorgji Kjosev
03/19/2022, 5:22 PMthdxr
03/19/2022, 5:42 PMthdxr
03/19/2022, 5:43 PMthdxr
03/19/2022, 5:51 PMthdxr
03/19/2022, 5:59 PMGjorgji Kjosev
03/19/2022, 6:11 PMGjorgji Kjosev
03/19/2022, 6:11 PMGjorgji Kjosev
03/19/2022, 6:12 PMtype ParamsType<SRC> = SRC extends [infer Params, infer Result] ? Params : { [K in keyof SRC]: ParamsType<SRC[K]> };
Gjorgji Kjosev
03/19/2022, 6:12 PMGjorgji Kjosev
03/19/2022, 6:12 PMquery{ stuff here }
thdxr
03/20/2022, 4:51 AMGjorgji Kjosev
03/20/2022, 3:35 PMthdxr
03/24/2022, 3:52 AMthdxr
03/24/2022, 2:17 PMGjorgji Kjosev
03/24/2022, 2:55 PMGjorgji Kjosev
03/24/2022, 2:56 PMGjorgji Kjosev
03/24/2022, 3:02 PMGjorgji Kjosev
03/24/2022, 3:06 PMGjorgji Kjosev
03/24/2022, 3:09 PMthdxr
03/24/2022, 3:13 PMthdxr
03/24/2022, 3:13 PMGjorgji Kjosev
03/24/2022, 3:14 PMGjorgji Kjosev
03/24/2022, 3:15 PMGjorgji Kjosev
03/24/2022, 3:15 PMtypeof GetType<X>
where X is any subset of the schemathdxr
03/24/2022, 3:15 PMthdxr
03/24/2022, 3:16 PMGjorgji Kjosev
03/24/2022, 3:17 PMGjorgji Kjosev
03/24/2022, 3:18 PMcreateQuery((vars, q) => q({user: [{id: vars.id}, {name: true}]}))
thdxr
03/24/2022, 3:18 PMthdxr
03/24/2022, 3:19 PMGjorgji Kjosev
03/24/2022, 3:19 PMvars.id
as well as its typeGjorgji Kjosev
03/24/2022, 3:19 PMthdxr
03/24/2022, 3:20 PMGjorgji Kjosev
03/24/2022, 3:20 PMGjorgji Kjosev
03/24/2022, 3:22 PMthdxr
03/24/2022, 3:23 PMJulien Goux
03/24/2022, 3:24 PMthdxr
03/24/2022, 3:24 PMthdxr
03/24/2022, 3:24 PMJulien Goux
03/24/2022, 3:24 PMthdxr
03/24/2022, 3:25 PMthdxr
03/24/2022, 3:25 PMthdxr
03/24/2022, 3:26 PMimport { sdk } from './generated'
const UserQuery = sdk.query({
name: "UserById",
variables: {
userId: "ID!"
},
selection: {
user: {
[sdk.arguments]: {
byId: "userId"
},
id: true,
login: true,
},
},
});
thdxr
03/24/2022, 3:26 PM[sdk.arguments]
symbolthdxr
03/24/2022, 3:27 PMJulien Goux
03/24/2022, 3:28 PMthdxr
03/24/2022, 3:28 PMJulien Goux
03/24/2022, 3:28 PMthdxr
03/24/2022, 3:28 PMJulien Goux
03/24/2022, 3:29 PMJulien Goux
03/24/2022, 3:30 PMthdxr
03/24/2022, 3:32 PMJulien Goux
03/24/2022, 3:35 PMthdxr
03/24/2022, 3:39 PMthdxr
03/24/2022, 3:40 PMthdxr
03/24/2022, 3:40 PMGjorgji Kjosev
03/24/2022, 8:49 PMDamjan
04/12/2022, 12:46 PMthdxr
04/12/2022, 12:51 PMthdxr
04/12/2022, 12:52 PMthdxr
04/12/2022, 12:52 PMDamjan
04/12/2022, 12:53 PMthdxr
04/12/2022, 12:56 PMthdxr
04/12/2022, 12:57 PMDamjan
04/12/2022, 2:45 PMthdxr
04/12/2022, 2:58 PMthdxr
04/12/2022, 2:58 PMimport { builder } from "./builder"
import "./types/auth"
import "./types/business"
import "./types/workspace"
import "./types/user"
import "./types/session"
import "./types/customer"
export const schema = builder.toSchema({})
Damjan
04/12/2022, 2:58 PMthdxr
04/12/2022, 2:59 PMDamjan
04/12/2022, 2:59 PMthdxr
04/12/2022, 3:00 PMbuilder.queryFields((t) => ({
rootSession: t.field({
type: RootSessionType,
resolve: async () => {
const actor = context().assert.root()
const session = await Auth.getCredentials(actor.properties.id)
return session!
},
}),
credentials: t.field({
type: CredentialsType,
resolve: async () => {
const user = context().assert.user()
return user
},
}),
}))
thdxr
04/12/2022, 3:00 PMDamjan
04/12/2022, 3:01 PMimport { builder } from './Builder'
import { HelloQuery } from './Query/Hello'
builder.queryType({
fields: (t) => ({
hello: HelloQuery,
}),
})
This is my serverDamjan
04/12/2022, 3:02 PMthdxr
04/12/2022, 3:02 PMDamjan
04/12/2022, 4:51 PMDamjan
04/12/2022, 4:55 PMthdxr
04/12/2022, 4:57 PMbuilder
along with this:
https://serverless-stack.slack.com/archives/C01HYQRUGG6/p1649775512683619?thread_ts=1647464288.737719&cid=C01HYQRUGG6Damjan
04/12/2022, 4:58 PM./types/auth
have access to builder ?thdxr
04/12/2022, 4:59 PM./builder
thdxr
04/12/2022, 4:59 PMbuilder.ts
thdxr
04/12/2022, 4:59 PMimport SchemaBuilder from "@pothos/core"
import { Context } from "@bumi/core/context"
import { JSONResolver, DateResolver, LocalDateResolver } from "graphql-scalars"
import RelayPlugin from "@pothos/plugin-relay"
import { decodeTime } from "ulid"
import { VisibleError } from "@bumi/core/errors"
export const builder = new SchemaBuilder<{
Context: Context
Scalars: {
ID: {
Input: string
Output: string
}
Date: {
Input: Date
Output: string
}
LocalDate: {
Input: string
Output: string
}
JSON: {
Input: string
Output: string
}
}
}>({
plugins: [RelayPlugin],
relayOptions: {},
})
builder.scalarType("ID", {
serialize: (x) => x,
parseValue: (x) => {
if (typeof x !== "string" || !decodeTime(x))
throw new VisibleError(`Invalid ULID: ${x}`)
return x
},
})
builder.addScalarType("JSON", JSONResolver, {})
builder.addScalarType("Date", DateResolver, {})
builder.addScalarType("LocalDate", LocalDateResolver, {})
builder.queryType({})
builder.mutationType({})
thdxr
04/12/2022, 5:00 PMthdxr
04/12/2022, 5:00 PMimport { builder } from "../builder"
import { Workspace } from "@bumi/core/workspace"
import { WorkspaceType } from "./workspace"
import { User } from "@bumi/core/user"
export const UserType = builder
.objectRef<User.UserEntityType>("User")
.implement({
fields: (t) => ({
id: t.exposeID("userID"),
email: t.exposeString("email"),
workspace: t.field({
type: WorkspaceType,
resolve: (user) => Workspace.fromID(user.workspaceID),
}),
}),
})
Damjan
04/12/2022, 5:00 PMbuilder.queryType({})
builder.mutationType({})
thdxr
04/12/2022, 5:00 PMDamjan
04/12/2022, 5:01 PMDamjan
04/12/2022, 5:01 PMGjorgji Kjosev
04/20/2022, 2:02 PM$
which you can use to form variables i.e. `$`id`` 🤕Gjorgji Kjosev
04/20/2022, 2:02 PMthdxr
04/20/2022, 2:02 PMthdxr
04/20/2022, 2:03 PMGjorgji Kjosev
04/21/2022, 10:35 PMGjorgji Kjosev
04/21/2022, 10:36 PMGjorgji Kjosev
04/21/2022, 10:37 PMconst q = tq({
cardById: [
{
cardId: $$('test'),
},
{
Attack: true,
Defense: true,
},
],
});
this is the APIGjorgji Kjosev
04/21/2022, 10:37 PMGjorgji Kjosev
04/21/2022, 10:37 PMconst q: TypedDocumentNode<{
cardById?: {
Attack: number;
Defense: number;
} | undefined;
}, {
test: string | null | undefined;
}>
Gjorgji Kjosev
04/21/2022, 10:38 PMGjorgji Kjosev
04/21/2022, 10:56 PMthdxr
04/21/2022, 11:28 PMGjorgji Kjosev
04/22/2022, 6:00 PMGjorgji Kjosev
04/22/2022, 6:14 PMGjorgji Kjosev
04/22/2022, 6:24 PMGjorgji Kjosev
04/27/2022, 1:06 PMGjorgji Kjosev
04/30/2022, 11:52 PMGjorgji Kjosev
04/30/2022, 11:53 PMand
and or
conditions), standard selection in tql style (but without mandatory method calls for fields), aliases