Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependency @devoxa/eslint-config from 3.0.11 to 4.0.0 #976

Merged
merged 5 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": { "source.organizeImports": true },
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
"[typescript]": { "editor.formatOnSave": true },
"[json]": { "editor.formatOnSave": true },
"[prisma]": { "editor.formatOnSave": true, "editor.defaultFormatter": "Prisma.prisma" },
Expand Down
5 changes: 5 additions & 0 deletions eslint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = require('@devoxa/eslint-config')

module.exports = config({
ignoreFiles: ['.gitignore'],
})
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@
"test": "jest",
"format": "prettier --ignore-path='.gitignore' --list-different --write .",
"format:check": "prettier --ignore-path='.gitignore' --check .",
"lint": "eslint --ignore-path='.gitignore' '{src,tests}/**/*.ts'",
"lint": "eslint '{src,tests}/**/*.ts'",
"build": "rm -rf dist/ && tsc",
"preversion": "yarn build"
},
"eslintConfig": {
"extends": "@devoxa"
},
"prettier": "@devoxa/prettier-config",
"dependencies": {
"graphql-fields": "2.0.3"
Expand All @@ -27,15 +24,15 @@
"@prisma/client": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0"
},
"devDependencies": {
"@devoxa/eslint-config": "3.0.11",
"@devoxa/eslint-config": "4.0.0",
"@devoxa/prettier-config": "2.0.3",
"@prisma/client": "6.0.1",
"@swc/core": "1.10.0",
"@swc/jest": "0.2.37",
"@types/graphql-fields": "1.3.9",
"@types/jest": "29.5.14",
"@types/node": "20.9.5",
"eslint": "8.57.1",
"eslint": "9.16.0",
"jest": "29.7.0",
"prettier": "3.4.2",
"prisma": "6.0.1",
Expand Down
10 changes: 8 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ export async function findManyCursorConnection<
}

const options = mergeDefaultOptions(pOptions)
const requestedFields = options.resolveInfo && Object.keys(graphqlFields(options.resolveInfo))
const hasRequestedField = (key: string) => !requestedFields || requestedFields.includes(key)

let requestedFields: Array<string> | undefined = undefined
if (options.resolveInfo) {
const _graphqlFields = graphqlFields(options.resolveInfo) as { [key: string]: unknown }
requestedFields = Object.keys(_graphqlFields)
}
const hasRequestedField = (key: string): boolean =>
!requestedFields || requestedFields.includes(key)

let records: Array<Record>
let totalCount: number
Expand Down
41 changes: 19 additions & 22 deletions tests/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { mocked } from 'jest-mock'
import { ConnectionArguments, findManyCursorConnection } from '../src'
import { PROFILE_FIXTURES, TODO_FIXTURES, USER_FIXTURES } from './fixtures'

function encodeCursor<Cursor>(prismaCursor: Cursor) {
function encodeCursor<Cursor>(prismaCursor: Cursor): string {
return Buffer.from(JSON.stringify(prismaCursor)).toString('base64')
}

function decodeCursor(cursor: string) {
function decodeCursor<Cursor>(cursor: string): Cursor {
return JSON.parse(Buffer.from(cursor, 'base64').toString('ascii'))
}

Expand All @@ -21,7 +21,7 @@ describe('prisma-relay-cursor-connection', () => {
jest.setTimeout(10000)
let client: PrismaClient

beforeAll(async () => {
beforeAll(() => {
client = new PrismaClient()
})

Expand Down Expand Up @@ -89,22 +89,22 @@ describe('prisma-relay-cursor-connection', () => {
expect(result).toMatchSnapshot()

// Test that the return types work via TS
result.edges[0].node.isCompleted
expect(result.edges[0].node.isCompleted)

// @ts-expect-error Typo in selected field
result.edges[0].node.isCompletedd
expect(result.edges[0].node.isCompletedd)

// @ts-expect-error Not selected field
result.edges[0].node.text
expect(result.edges[0].node.text)

// Test that the return types work via TS
result.nodes[0].isCompleted
expect(result.nodes[0].isCompleted)

// @ts-expect-error Typo in selected field
result.nodes[0].isCompletedd
expect(result.nodes[0].isCompletedd)

// @ts-expect-error Not selected field
result.nodes[0].text
expect(result.nodes[0].text)
})
})

Expand Down Expand Up @@ -200,22 +200,22 @@ describe('prisma-relay-cursor-connection', () => {
expect(result).toMatchSnapshot()

// Test that the return types work via TS
result.edges[0].node.email
expect(result.edges[0].node.email)

// @ts-expect-error Typo in selected field
result.edges[0].node.emmail
expect(result.edges[0].node.emmail)

// @ts-expect-error Not selected field
result.edges[0].node.text
expect(result.edges[0].node.text)

// Test that the return types work via TS
result.nodes[0].email
expect(result.nodes[0].email)

// @ts-expect-error Typo in selected field
result.nodes[0].emmail
expect(result.nodes[0].emmail)

// @ts-expect-error Not selected field
result.nodes[0].text
expect(result.nodes[0].text)
})
})

Expand Down Expand Up @@ -469,13 +469,13 @@ describe('prisma-relay-cursor-connection', () => {
expect(result).toMatchSnapshot()

// Test that the node.extraNodeField return types work via TS
result.edges[0]?.node.extraNodeField
expect(result.edges[0]?.node.extraNodeField)

// Test that the extraEdgeField return type work via TS
result.edges[0]?.extraEdgeField
expect(result.edges[0]?.extraEdgeField)

// Test that the node.extraNodeField return types work via TS
result.nodes[0]?.extraNodeField
expect(result.nodes[0]?.extraNodeField)
})
})

Expand Down Expand Up @@ -564,8 +564,7 @@ describe('prisma-relay-cursor-connection', () => {
})

// These are not real tests which run, but rather a way to ensure that the types are correct
// when tsc runs
const typecheckForInferredTypes = async () => {
export const typecheckForInferredTypes = async (): Promise<void> => {
const client = new PrismaClient()

// Default will get the inferred types from prisma
Expand Down Expand Up @@ -610,5 +609,3 @@ const typecheckForInferredTypes = async () => {
}[]
}
}

typecheckForInferredTypes
Loading