Skip to content

Commit

Permalink
Update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
realparadise committed May 22, 2023
1 parent 807d29a commit 85e7708
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 229 deletions.
6 changes: 5 additions & 1 deletion .graphqlrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/** @type {import('@graphql-codegen/cli').CodegenConfig} */
const config = {
schema: 'src/lib/graphql/schema.graphql',
documents: ['src/pages/**.tsx', 'src/components/**.tsx', '!src/gql/**/*'],
documents: [
'src/pages/**.tsx',
'src/components/**.tsx',
'!src/lib/graphql/**/*',
],
generates: {
'./src/lib/graphql/': {
preset: 'client',
Expand Down
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
},
"dependencies": {
"@next-auth/prisma-adapter": "1.0.6",
"@pothos/core": "3.29.0",
"@pothos/plugin-prisma": "3.47.2",
"@pothos/plugin-scope-auth": "3.19.0",
"@prisma/client": "4.13.0",
"@pothos/core": "3.30.0",
"@pothos/plugin-prisma": "3.51.1",
"@pothos/plugin-scope-auth": "3.19.2",
"@prisma/client": "4.14.1",
"graphql": "16.6.0",
"graphql-yoga": "3.9.1",
"next": "13.3.0",
"next": "13.4.3",
"next-auth": "4.22.1",
"next-urql": "3.3.3",
"react": "18.2.0",
Expand All @@ -36,17 +36,17 @@
},
"devDependencies": {
"@graphql-codegen/cli": "3.3.0",
"@graphql-codegen/client-preset-swc-plugin": "0.1.3",
"@graphql-codegen/client-preset": "2.1.0",
"@types/node": "18.15.12",
"@types/react": "18.0.37",
"eslint-config-next": "13.3.0",
"@graphql-codegen/client-preset": "3.0.1",
"@graphql-codegen/client-preset-swc-plugin": "0.2.0",
"@types/node": "20.2.3",
"@types/react": "18.2.6",
"eslint": "8.38.0",
"eslint-config-next": "13.4.3",
"husky": "8.0.3",
"prettier": "2.8.7",
"pretty-quick": "3.1.3",
"prisma": "4.13.0",
"prisma": "4.14.1",
"tsx": "3.12.6",
"typescript": "4.9.5"
"typescript": "5.0.4"
}
}
42 changes: 23 additions & 19 deletions src/lib/graphql/fragment-masking.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,57 @@
import {
ResultOf,
TypedDocumentNode as DocumentNode,
DocumentTypeDecoration,
} from '@graphql-typed-document-node/core'

export type FragmentType<TDocumentType extends DocumentNode<any, any>> =
TDocumentType extends DocumentNode<infer TType, any>
? TType extends { ' $fragmentName'?: infer TKey }
? TKey extends string
? { ' $fragmentRefs'?: { [key in TKey]: TType } }
: never
export type FragmentType<
TDocumentType extends DocumentTypeDecoration<any, any>
> = TDocumentType extends DocumentTypeDecoration<infer TType, any>
? TType extends { ' $fragmentName'?: infer TKey }
? TKey extends string
? { ' $fragmentRefs'?: { [key in TKey]: TType } }
: never
: never
: never

// return non-nullable if `fragmentType` is non-nullable
export function useFragment<TType>(
_documentNode: DocumentNode<TType, any>,
fragmentType: FragmentType<DocumentNode<TType, any>>
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>>
): TType
// return nullable if `fragmentType` is nullable
export function useFragment<TType>(
_documentNode: DocumentNode<TType, any>,
fragmentType: FragmentType<DocumentNode<TType, any>> | null | undefined
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType:
| FragmentType<DocumentTypeDecoration<TType, any>>
| null
| undefined
): TType | null | undefined
// return array of non-nullable if `fragmentType` is array of non-nullable
export function useFragment<TType>(
_documentNode: DocumentNode<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentNode<TType, any>>>
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
): ReadonlyArray<TType>
// return array of nullable if `fragmentType` is array of nullable
export function useFragment<TType>(
_documentNode: DocumentNode<TType, any>,
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType:
| ReadonlyArray<FragmentType<DocumentNode<TType, any>>>
| ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
| null
| undefined
): ReadonlyArray<TType> | null | undefined
export function useFragment<TType>(
_documentNode: DocumentNode<TType, any>,
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType:
| FragmentType<DocumentNode<TType, any>>
| ReadonlyArray<FragmentType<DocumentNode<TType, any>>>
| FragmentType<DocumentTypeDecoration<TType, any>>
| ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
| null
| undefined
): TType | ReadonlyArray<TType> | null | undefined {
return fragmentType as any
}

export function makeFragmentData<
F extends DocumentNode,
F extends DocumentTypeDecoration<any, any>,
FT extends ResultOf<F>
>(data: FT, _fragment: F): FragmentType<F> {
return data as FragmentType<F>
Expand Down
Loading

0 comments on commit 85e7708

Please sign in to comment.