houdini 0.17.8 → 0.17.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/README.md +33 -0
  2. package/build/cmd-cjs/index.js +124 -38
  3. package/build/cmd-esm/index.js +124 -38
  4. package/build/codegen-cjs/index.js +112 -36
  5. package/build/codegen-esm/index.js +112 -36
  6. package/build/lib/config.d.ts +3 -0
  7. package/build/lib-cjs/index.js +31 -12
  8. package/build/lib-esm/index.js +31 -12
  9. package/build/runtime/cache/cache.d.ts +1 -1
  10. package/build/runtime/cache/lists.d.ts +1 -1
  11. package/build/runtime/lib/config.d.ts +10 -2
  12. package/build/runtime/lib/types.d.ts +1 -0
  13. package/build/runtime-cjs/cache/cache.d.ts +1 -1
  14. package/build/runtime-cjs/cache/cache.js +6 -6
  15. package/build/runtime-cjs/cache/lists.d.ts +1 -1
  16. package/build/runtime-cjs/cache/lists.js +15 -6
  17. package/build/runtime-cjs/cache/tests/list.test.js +160 -70
  18. package/build/runtime-cjs/lib/config.d.ts +10 -2
  19. package/build/runtime-cjs/lib/types.d.ts +1 -0
  20. package/build/runtime-esm/cache/cache.d.ts +1 -1
  21. package/build/runtime-esm/cache/cache.js +6 -6
  22. package/build/runtime-esm/cache/lists.d.ts +1 -1
  23. package/build/runtime-esm/cache/lists.js +15 -6
  24. package/build/runtime-esm/cache/tests/list.test.js +160 -70
  25. package/build/runtime-esm/lib/config.d.ts +10 -2
  26. package/build/runtime-esm/lib/types.d.ts +1 -0
  27. package/build/test-cjs/index.js +122 -36
  28. package/build/test-esm/index.js +122 -36
  29. package/build/vite-cjs/index.js +122 -36
  30. package/build/vite-esm/index.js +122 -36
  31. package/package.json +16 -1
  32. package/.turbo/turbo-compile.log +0 -5
  33. package/.turbo/turbo-typedefs.log +0 -5
  34. package/CHANGELOG.md +0 -367
  35. package/src/cmd/generate.ts +0 -54
  36. package/src/cmd/index.ts +0 -60
  37. package/src/cmd/init.ts +0 -637
  38. package/src/cmd/pullSchema.ts +0 -40
  39. package/src/codegen/generators/artifacts/artifacts.test.ts +0 -2978
  40. package/src/codegen/generators/artifacts/fieldKey.ts +0 -60
  41. package/src/codegen/generators/artifacts/index.ts +0 -330
  42. package/src/codegen/generators/artifacts/indexFile.ts +0 -24
  43. package/src/codegen/generators/artifacts/inputs.ts +0 -81
  44. package/src/codegen/generators/artifacts/operations.ts +0 -263
  45. package/src/codegen/generators/artifacts/pagination.test.ts +0 -664
  46. package/src/codegen/generators/artifacts/policy.test.ts +0 -298
  47. package/src/codegen/generators/artifacts/selection.ts +0 -208
  48. package/src/codegen/generators/artifacts/utils.test.ts +0 -118
  49. package/src/codegen/generators/artifacts/utils.ts +0 -108
  50. package/src/codegen/generators/definitions/enums.test.ts +0 -61
  51. package/src/codegen/generators/definitions/enums.ts +0 -68
  52. package/src/codegen/generators/definitions/index.ts +0 -11
  53. package/src/codegen/generators/definitions/schema.test.ts +0 -227
  54. package/src/codegen/generators/index.ts +0 -6
  55. package/src/codegen/generators/indexFile/index.ts +0 -63
  56. package/src/codegen/generators/indexFile/indexFile.test.ts +0 -72
  57. package/src/codegen/generators/persistedQueries/index.ts +0 -55
  58. package/src/codegen/generators/persistedQueries/persistedQuery.test.ts +0 -26
  59. package/src/codegen/generators/runtime/index.test.ts +0 -74
  60. package/src/codegen/generators/runtime/index.ts +0 -64
  61. package/src/codegen/generators/runtime/runtime.test.ts +0 -25
  62. package/src/codegen/generators/typescript/addReferencedInputTypes.ts +0 -77
  63. package/src/codegen/generators/typescript/index.ts +0 -412
  64. package/src/codegen/generators/typescript/inlineType.ts +0 -409
  65. package/src/codegen/generators/typescript/typeReference.ts +0 -44
  66. package/src/codegen/generators/typescript/types.ts +0 -81
  67. package/src/codegen/generators/typescript/typescript.test.ts +0 -1434
  68. package/src/codegen/index.ts +0 -406
  69. package/src/codegen/transforms/addID.test.ts +0 -93
  70. package/src/codegen/transforms/addID.ts +0 -86
  71. package/src/codegen/transforms/composeQueries.test.ts +0 -50
  72. package/src/codegen/transforms/composeQueries.ts +0 -154
  73. package/src/codegen/transforms/fragmentVariables.test.ts +0 -636
  74. package/src/codegen/transforms/fragmentVariables.ts +0 -417
  75. package/src/codegen/transforms/index.ts +0 -7
  76. package/src/codegen/transforms/list.ts +0 -485
  77. package/src/codegen/transforms/lists.test.ts +0 -530
  78. package/src/codegen/transforms/paginate.test.ts +0 -1481
  79. package/src/codegen/transforms/paginate.ts +0 -750
  80. package/src/codegen/transforms/schema.test.ts +0 -136
  81. package/src/codegen/transforms/schema.ts +0 -104
  82. package/src/codegen/transforms/typename.test.ts +0 -125
  83. package/src/codegen/transforms/typename.ts +0 -55
  84. package/src/codegen/utils/commonjs.ts +0 -26
  85. package/src/codegen/utils/flattenSelections.ts +0 -179
  86. package/src/codegen/utils/graphql.test.ts +0 -35
  87. package/src/codegen/utils/graphql.ts +0 -79
  88. package/src/codegen/utils/index.ts +0 -5
  89. package/src/codegen/utils/moduleExport.ts +0 -27
  90. package/src/codegen/utils/murmur.ts +0 -79
  91. package/src/codegen/validators/index.ts +0 -4
  92. package/src/codegen/validators/noIDAlias.test.ts +0 -71
  93. package/src/codegen/validators/noIDAlias.ts +0 -39
  94. package/src/codegen/validators/plugins.ts +0 -25
  95. package/src/codegen/validators/typeCheck.test.ts +0 -904
  96. package/src/codegen/validators/typeCheck.ts +0 -1031
  97. package/src/codegen/validators/uniqueNames.test.ts +0 -59
  98. package/src/codegen/validators/uniqueNames.ts +0 -39
  99. package/src/lib/cleanupFiles.ts +0 -20
  100. package/src/lib/config.test.ts +0 -13
  101. package/src/lib/config.ts +0 -943
  102. package/src/lib/constants.ts +0 -11
  103. package/src/lib/error.ts +0 -24
  104. package/src/lib/fs.ts +0 -285
  105. package/src/lib/graphql.test.ts +0 -211
  106. package/src/lib/graphql.ts +0 -200
  107. package/src/lib/imports.ts +0 -82
  108. package/src/lib/index.ts +0 -17
  109. package/src/lib/introspection.ts +0 -39
  110. package/src/lib/parse.test.ts +0 -75
  111. package/src/lib/parse.ts +0 -23
  112. package/src/lib/path.ts +0 -49
  113. package/src/lib/pipeline.ts +0 -17
  114. package/src/lib/types.ts +0 -34
  115. package/src/lib/walk.ts +0 -104
  116. package/src/runtime/cache/cache.ts +0 -1023
  117. package/src/runtime/cache/gc.ts +0 -56
  118. package/src/runtime/cache/index.ts +0 -3
  119. package/src/runtime/cache/lists.ts +0 -502
  120. package/src/runtime/cache/storage.ts +0 -574
  121. package/src/runtime/cache/stuff.ts +0 -77
  122. package/src/runtime/cache/subscription.ts +0 -329
  123. package/src/runtime/cache/tests/availability.test.ts +0 -408
  124. package/src/runtime/cache/tests/gc.test.ts +0 -319
  125. package/src/runtime/cache/tests/keys.test.ts +0 -36
  126. package/src/runtime/cache/tests/list.test.ts +0 -3747
  127. package/src/runtime/cache/tests/readwrite.test.ts +0 -1201
  128. package/src/runtime/cache/tests/scalars.test.ts +0 -218
  129. package/src/runtime/cache/tests/storage.test.ts +0 -426
  130. package/src/runtime/cache/tests/subscriptions.test.ts +0 -1757
  131. package/src/runtime/index.ts +0 -29
  132. package/src/runtime/lib/config.ts +0 -201
  133. package/src/runtime/lib/constants.ts +0 -17
  134. package/src/runtime/lib/deepEquals.ts +0 -32
  135. package/src/runtime/lib/errors.ts +0 -8
  136. package/src/runtime/lib/index.ts +0 -8
  137. package/src/runtime/lib/log.ts +0 -69
  138. package/src/runtime/lib/network.ts +0 -303
  139. package/src/runtime/lib/networkUtils.ts +0 -151
  140. package/src/runtime/lib/scalars.test.ts +0 -877
  141. package/src/runtime/lib/scalars.ts +0 -195
  142. package/src/runtime/lib/types.ts +0 -194
  143. package/src/test/index.ts +0 -294
  144. package/src/vite/ast.ts +0 -107
  145. package/src/vite/houdini.ts +0 -113
  146. package/src/vite/imports.ts +0 -129
  147. package/src/vite/index.ts +0 -55
  148. package/src/vite/schema.ts +0 -80
@@ -1,263 +0,0 @@
1
- import * as graphql from 'graphql'
2
-
3
- import { Config, HoudiniError, parentTypeFromAncestors } from '../../../lib'
4
- import { MutationOperation } from '../../../runtime/lib/types'
5
- import { convertValue } from './utils'
6
-
7
- // return the list of operations that are part of a mutation
8
- export function operationsByPath(
9
- config: Config,
10
- filepath: string,
11
- definition: graphql.OperationDefinitionNode,
12
- filterTypes: FilterMap
13
- ): { [path: string]: MutationOperation[] } {
14
- if (!definition) {
15
- return {}
16
- }
17
-
18
- // map the path in the response to the list of operations that treat it as the source
19
- const pathOperations: { [path: string]: MutationOperation[] } = {}
20
-
21
- // we need to look for three different things in the operation:
22
- // - insert fragments
23
- // - remove fragments
24
- // - delete directives
25
- //
26
- // note: for now, we're going to ignore the possibility that fragments
27
- // inside of the mutation could contain operations
28
- graphql.visit(definition, {
29
- FragmentSpread(node, _, __, ___, ancestors) {
30
- // if the fragment is not a list operation, we don't care about it now
31
- if (!config.isListFragment(node.name.value)) {
32
- return
33
- }
34
-
35
- // if this is the first time we've seen this path give us a home
36
- const path = ancestorKey(ancestors)
37
- if (!pathOperations[path]) {
38
- pathOperations[path] = []
39
- }
40
-
41
- // add the operation object to the list
42
- pathOperations[path].push(
43
- operationObject({
44
- config,
45
- filepath,
46
- listName: config.listNameFromFragment(node.name.value),
47
- operationKind: config.listOperationFromFragment(node.name.value),
48
- type: parentTypeFromAncestors(config.schema, filepath, ancestors).name,
49
- selection: node,
50
- })
51
- )
52
- },
53
- Directive(node, _, __, ___, ancestors) {
54
- // we only care about delete directives
55
- if (!config.isDeleteDirective(node.name.value)) {
56
- return
57
- }
58
-
59
- // if this is the first time we've seen this path give us a home
60
- const path = ancestorKey(ancestors)
61
- if (!pathOperations[path]) {
62
- pathOperations[path] = []
63
- }
64
-
65
- // add the operation object to the list
66
- pathOperations[path].push(
67
- operationObject({
68
- config,
69
- filepath,
70
- listName: node.name.value,
71
- operationKind: 'delete',
72
- type: config.listNameFromDirective(node.name.value),
73
- selection: ancestors[ancestors.length - 1] as graphql.FieldNode,
74
- })
75
- )
76
- },
77
- })
78
-
79
- return pathOperations
80
- }
81
-
82
- function operationObject({
83
- config,
84
- listName,
85
- operationKind,
86
- type,
87
- selection,
88
- filepath,
89
- }: {
90
- config: Config
91
- filepath: string
92
- listName: string
93
- operationKind: MutationOperation['action']
94
- type: string
95
- selection: graphql.SelectionNode
96
- }): MutationOperation {
97
- // look at the directives applies to the spread for meta data about the mutation
98
- let parentID
99
- let parentKind: 'Variable' | 'String' = 'String'
100
-
101
- let position: MutationOperation['position'] = 'last'
102
- let operationWhen: MutationOperation['when'] | undefined
103
-
104
- const internalDirectives = selection.directives?.filter((directive) =>
105
- config.isInternalDirective(directive)
106
- )
107
- if (internalDirectives && internalDirectives.length > 0) {
108
- // is prepend applied?
109
- const prepend = internalDirectives.find(
110
- ({ name }) => name.value === config.listPrependDirective
111
- )
112
- // is append applied?
113
- const append = internalDirectives.find(
114
- ({ name }) => name.value === config.listAppendDirective
115
- )
116
- // is when applied?
117
- const when = internalDirectives.find(({ name }) => name.value === 'when')
118
- // is when_not applied?
119
- const when_not = internalDirectives.find(({ name }) => name.value === 'when_not')
120
- // look for the parentID directive
121
- let parent = internalDirectives.find(
122
- ({ name }) => name.value === config.listParentDirective
123
- )
124
-
125
- // if both are applied, there's a problem
126
- if (append && prepend) {
127
- throw new HoudiniError({ filepath, message: 'you have both applied' })
128
- }
129
- position = prepend ? 'first' : 'last'
130
-
131
- // the parent ID can be provided a few ways, either as an argument to the prepend
132
- // and append directives or with the parentID directive.
133
-
134
- let parentIDArg = parent?.arguments?.find((argument) => argument.name.value === 'value')
135
- // if there is no parent id argument, it could have been provided by one of the list directives
136
- if (!parentIDArg) {
137
- parentIDArg = (append || prepend)?.arguments?.find(
138
- ({ name }) => name.value === config.listDirectiveParentIDArg
139
- )
140
- }
141
-
142
- if (parentIDArg) {
143
- // if the argument is a string
144
- if (parentIDArg.value.kind === 'StringValue') {
145
- // use its value
146
- parentID = parentIDArg.value.value
147
- parentKind = 'String'
148
- } else if (parentIDArg.value.kind === 'Variable') {
149
- parentKind = 'Variable'
150
- parentID = parentIDArg.value.name.value
151
- }
152
- }
153
-
154
- // look for a when arguments on the operation directives
155
- const whenArg = (append || prepend)?.arguments?.find(({ name }) => name.value === 'when')
156
- // look for a when_not condition on the operation
157
- const whenNotArg = (append || prepend)?.arguments?.find(
158
- ({ name }) => name.value === 'when_not'
159
- )
160
-
161
- for (const [i, arg] of [whenArg, whenNotArg].entries()) {
162
- // we may not have the argument
163
- if (!arg || arg.value.kind !== 'ObjectValue') {
164
- continue
165
- }
166
-
167
- // make sure we have a place to record the when condition
168
- if (!operationWhen) {
169
- operationWhen = {}
170
- }
171
-
172
- // the kind of `value` is always going to be a string because the directive
173
- // can only take one type as its argument so we'll worry about parsing when
174
- // generating the artifact
175
- operationWhen[i ? 'must_not' : 'must'] = arg.value.fields.reduce(
176
- (obj, arg) => ({
177
- ...obj,
178
- [arg.name.value]: convertValue(arg.value).value,
179
- }),
180
- {}
181
- )
182
- }
183
-
184
- // look at the when and when_not directives
185
- for (const [i, directive] of [when, when_not].entries()) {
186
- // we may not have the directive applied
187
- if (!directive) {
188
- continue
189
- }
190
- // which are we looking at
191
- const which = i ? 'must_not' : 'must'
192
-
193
- // make sure we have a place to record the when condition
194
- if (!operationWhen) {
195
- operationWhen = {}
196
- }
197
-
198
- // look for the argument field
199
- operationWhen[which] = directive.arguments?.reduce(
200
- (filters, argument) => ({
201
- ...filters,
202
- [argument.name.value]: convertValue(argument.value).value,
203
- }),
204
- {}
205
- )
206
- }
207
- }
208
-
209
- const operation: MutationOperation = {
210
- action: operationKind,
211
- }
212
-
213
- // delete doesn't have a target
214
- if (operationKind !== 'delete') {
215
- operation.list = listName
216
- }
217
-
218
- // add the target type to delete operations
219
- if (operationKind === 'delete' && type) {
220
- operation.type = type
221
- }
222
-
223
- // only add the position argument if we are inserting something
224
- if (operationKind === 'insert' || operationKind === 'toggle') {
225
- operation.position = position || 'last'
226
- }
227
-
228
- // if there is a parent id
229
- if (parentID) {
230
- // add it to the object
231
- operation.parentID = {
232
- kind: parentKind,
233
- value: parentID,
234
- }
235
- }
236
-
237
- // if there is a conditional
238
- if (operationWhen) {
239
- operation.when = operationWhen
240
- }
241
-
242
- return operation
243
- }
244
-
245
- // TODO: find a way to reference the actual type for ancestors, using any as escape hatch
246
- function ancestorKey(ancestors: any): string {
247
- return (
248
- ancestors
249
- .filter(
250
- // @ts-ignore
251
- (entry) => !Array.isArray(entry) && entry.kind === 'Field'
252
- )
253
- // @ts-ignore
254
- .map((field) => field.name.value)
255
- .join(',')
256
- )
257
- }
258
-
259
- export type FilterMap = {
260
- [listName: string]: {
261
- [filterName: string]: 'String' | 'Float' | 'Int' | 'Boolean'
262
- }
263
- }