My personal helpers and types for GraphQL
oneToManyLoader()
oneToOneLoader()
OneToManyLoader
OneToOneLoader
generatePaginatedResponse()
paginatedLoader()
paginationArgsToSql()
PageInfo
PaginatedLoader
PaginationArgs
PaginationResponse
Loaders
Schema
CustomContext
LoaderWithReturn
CustomResolver
Shallowing
These helpers are used with something like this config for https://the-guild.dev/graphql/codegen:
schema: './lib/graphql/schema.graphql'
# documents:
# - './lib/queries/**/*.{graphql,js}'
# - './views/**/*.{graphql,js}'
extensions:
languageService:
useSchemaFileDefinitions: true
codegen:
overwrite: true
emitLegacyCommonJSImports: false
config:
exportFragmentSpreadSubTypes: true
skipTypename: true
avoidOptionals: true
contextType: '@voxpelli/graphql-utils#CustomContext'
customResolverFn: '@voxpelli/graphql-utils#CustomResolver'
enumsAsTypes: true
immutableTypes: true
noSchemaStitching: true
wrapFieldDefinitions: false
resolverTypeWrapperSignature: T
useTypeImports: true
# TODO: What is this?
showUnusedMappers: true
scalars:
DateTime: Date
EmailAddress: string
JSONObject: JsonObject
NonEmptyString: string
UUID: string
generates:
lib/graphql/schema.d.ts:
plugins:
- add:
content: '// Automatically generated, do not change!'
- add:
content: "import type { JsonObject } from 'type-fest';"
- typescript
- typescript-resolvers
lib/graphql/:
preset: near-operation-file
presetConfig:
extension: -generated.d.ts
baseTypesPath: schema.js
plugins:
- add:
content: '// Automatically generated, do not change!'
- typescript-operations:
inlineFragmentTypes: 'combine'