Skip to content

Commit ef9546c

Browse files
committed
fix: formatting and lint issues
1 parent 6630b32 commit ef9546c

File tree

3 files changed

+29
-30
lines changed

3 files changed

+29
-30
lines changed

src/extensions/DocumentBuilder/Select/$parseSelection.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Grafaid } from '../../../lib/grafaid/_namespace.js'
21
import { Select } from './../Select/__.js'
32
import type { SelectionSet } from './_.js'
43
import { Arguments, Directive, Indicator, InlineFragment, SelectAlias, SelectScalarsWildcard } from './_.js'

src/extensions/DocumentBuilder/SelectGraphQLMapper/nodes/Value.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ export const toGraphQLValue: ValueMapper = (context, sddm, value) => {
4242
return Nodes.ObjectValue({
4343
fields: Object.entries(value).map(([fieldName, fieldValue]) => {
4444
// Check if the original field name starts with $ (enum indicator)
45-
const isEnumField = fieldName.startsWith('$')
45+
const isEnumField = fieldName.startsWith(`$`)
4646
const actualFieldName = isEnumField ? fieldName.substring(1) : fieldName
47-
47+
4848
// Get the field's schema info using the actual field name (without $)
4949
const fieldSddm = sddmInputObject?.f?.[actualFieldName]
50-
50+
5151
// Update context if this is an enum field
5252
const fieldContext = isEnumField ? { ...context, value: { isEnum: true } } : context
53-
53+
5454
return Nodes.ObjectField({
5555
name: Nodes.Name({ value: actualFieldName }),
5656
value: toGraphQLValue(fieldContext, fieldSddm, fieldValue),

src/extensions/DocumentBuilder/enum-bug.test.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,36 @@ test('enum arguments in nested input objects should be handled correctly', () =>
88
// This test reproduces the bug from issue #1351
99
// When enum arguments are used in nested input objects with $ prefix,
1010
// they should be properly converted to GraphQL enum values, not strings
11-
12-
const graffleQuery = {
13-
stringWithArgInputObjectEnum: {
14-
$: {
15-
input: {
16-
$abcEnum: 'A'
17-
}
18-
}
19-
}
11+
12+
const graffleQuery = {
13+
stringWithArgInputObjectEnum: {
14+
$: {
15+
input: {
16+
$abcEnum: 'A',
17+
},
18+
},
19+
},
2020
}
21-
21+
2222
const documentNormalized = Select.Document.createDocumentNormalizedFromQuerySelection(
2323
graffleQuery,
2424
undefined,
2525
)
26-
26+
2727
const { document } = toGraphQLDocument(documentNormalized, {
2828
sddm: PossibleWithScalars.schemaMap,
2929
scalars: {},
3030
operationVariables: false,
3131
})
32-
32+
3333
const printed = Grafaid.Document.print(document)
34-
34+
3535
// The enum value should be unquoted in the GraphQL query
3636
// It should be: abcEnum: A
3737
// Not: abcEnum: "A"
3838
expect(printed).toMatch(/abcEnum:\s*A(?!\s*")/)
3939
expect(printed).not.toMatch(/abcEnum:\s*"A"/)
40-
40+
4141
// Full snapshot for clarity
4242
expect(printed).toMatchInlineSnapshot(`
4343
"{
@@ -47,28 +47,28 @@ test('enum arguments in nested input objects should be handled correctly', () =>
4747
})
4848

4949
test('enum arguments at top level should work correctly', () => {
50-
const graffleQuery = {
51-
stringWithArgEnum: {
52-
$: {
53-
$ABCEnum: 'A'
54-
}
55-
}
50+
const graffleQuery = {
51+
stringWithArgEnum: {
52+
$: {
53+
$ABCEnum: 'A',
54+
},
55+
},
5656
}
57-
57+
5858
const documentNormalized = Select.Document.createDocumentNormalizedFromQuerySelection(
5959
graffleQuery,
6060
undefined,
6161
)
62-
62+
6363
const { document } = toGraphQLDocument(documentNormalized, {
6464
sddm: PossibleWithScalars.schemaMap,
6565
scalars: {},
6666
operationVariables: false,
6767
})
68-
68+
6969
const printed = Grafaid.Document.print(document)
70-
70+
7171
// This should already work correctly
7272
expect(printed).toMatch(/ABCEnum:\s*A(?!\s*")/)
7373
expect(printed).not.toMatch(/ABCEnum:\s*"A"/)
74-
})
74+
})

0 commit comments

Comments
 (0)