houdini 0.17.9 → 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 (121) hide show
  1. package/README.md +33 -0
  2. package/build/cmd-cjs/index.js +2 -2
  3. package/build/cmd-esm/index.js +2 -2
  4. package/package.json +16 -1
  5. package/.turbo/turbo-compile.log +0 -5
  6. package/.turbo/turbo-typedefs.log +0 -5
  7. package/CHANGELOG.md +0 -377
  8. package/src/cmd/generate.ts +0 -54
  9. package/src/cmd/index.ts +0 -60
  10. package/src/cmd/init.ts +0 -637
  11. package/src/cmd/pullSchema.ts +0 -40
  12. package/src/codegen/generators/artifacts/artifacts.test.ts +0 -3246
  13. package/src/codegen/generators/artifacts/fieldKey.ts +0 -60
  14. package/src/codegen/generators/artifacts/index.ts +0 -330
  15. package/src/codegen/generators/artifacts/indexFile.ts +0 -24
  16. package/src/codegen/generators/artifacts/inputs.ts +0 -81
  17. package/src/codegen/generators/artifacts/operations.ts +0 -281
  18. package/src/codegen/generators/artifacts/pagination.test.ts +0 -664
  19. package/src/codegen/generators/artifacts/policy.test.ts +0 -298
  20. package/src/codegen/generators/artifacts/selection.ts +0 -208
  21. package/src/codegen/generators/artifacts/utils.test.ts +0 -118
  22. package/src/codegen/generators/artifacts/utils.ts +0 -108
  23. package/src/codegen/generators/definitions/enums.test.ts +0 -61
  24. package/src/codegen/generators/definitions/enums.ts +0 -68
  25. package/src/codegen/generators/definitions/index.ts +0 -11
  26. package/src/codegen/generators/definitions/schema.test.ts +0 -236
  27. package/src/codegen/generators/index.ts +0 -6
  28. package/src/codegen/generators/indexFile/index.ts +0 -63
  29. package/src/codegen/generators/indexFile/indexFile.test.ts +0 -72
  30. package/src/codegen/generators/persistedQueries/index.ts +0 -55
  31. package/src/codegen/generators/persistedQueries/persistedQuery.test.ts +0 -26
  32. package/src/codegen/generators/runtime/index.test.ts +0 -74
  33. package/src/codegen/generators/runtime/index.ts +0 -64
  34. package/src/codegen/generators/runtime/runtime.test.ts +0 -25
  35. package/src/codegen/generators/typescript/addReferencedInputTypes.ts +0 -77
  36. package/src/codegen/generators/typescript/index.ts +0 -412
  37. package/src/codegen/generators/typescript/inlineType.ts +0 -409
  38. package/src/codegen/generators/typescript/typeReference.ts +0 -44
  39. package/src/codegen/generators/typescript/types.ts +0 -81
  40. package/src/codegen/generators/typescript/typescript.test.ts +0 -1434
  41. package/src/codegen/index.ts +0 -406
  42. package/src/codegen/transforms/addID.test.ts +0 -93
  43. package/src/codegen/transforms/addID.ts +0 -86
  44. package/src/codegen/transforms/composeQueries.test.ts +0 -50
  45. package/src/codegen/transforms/composeQueries.ts +0 -154
  46. package/src/codegen/transforms/fragmentVariables.test.ts +0 -636
  47. package/src/codegen/transforms/fragmentVariables.ts +0 -417
  48. package/src/codegen/transforms/index.ts +0 -7
  49. package/src/codegen/transforms/list.ts +0 -484
  50. package/src/codegen/transforms/lists.test.ts +0 -530
  51. package/src/codegen/transforms/paginate.test.ts +0 -1528
  52. package/src/codegen/transforms/paginate.ts +0 -770
  53. package/src/codegen/transforms/schema.test.ts +0 -136
  54. package/src/codegen/transforms/schema.ts +0 -109
  55. package/src/codegen/transforms/typename.test.ts +0 -125
  56. package/src/codegen/transforms/typename.ts +0 -55
  57. package/src/codegen/utils/commonjs.ts +0 -26
  58. package/src/codegen/utils/flattenSelections.ts +0 -179
  59. package/src/codegen/utils/graphql.test.ts +0 -35
  60. package/src/codegen/utils/graphql.ts +0 -79
  61. package/src/codegen/utils/index.ts +0 -5
  62. package/src/codegen/utils/moduleExport.ts +0 -27
  63. package/src/codegen/utils/murmur.ts +0 -79
  64. package/src/codegen/validators/index.ts +0 -4
  65. package/src/codegen/validators/noIDAlias.test.ts +0 -71
  66. package/src/codegen/validators/noIDAlias.ts +0 -39
  67. package/src/codegen/validators/plugins.ts +0 -25
  68. package/src/codegen/validators/typeCheck.test.ts +0 -960
  69. package/src/codegen/validators/typeCheck.ts +0 -1086
  70. package/src/codegen/validators/uniqueNames.test.ts +0 -59
  71. package/src/codegen/validators/uniqueNames.ts +0 -39
  72. package/src/lib/cleanupFiles.ts +0 -20
  73. package/src/lib/config.test.ts +0 -13
  74. package/src/lib/config.ts +0 -954
  75. package/src/lib/constants.ts +0 -11
  76. package/src/lib/error.ts +0 -24
  77. package/src/lib/fs.ts +0 -285
  78. package/src/lib/graphql.test.ts +0 -211
  79. package/src/lib/graphql.ts +0 -200
  80. package/src/lib/imports.ts +0 -82
  81. package/src/lib/index.ts +0 -17
  82. package/src/lib/introspection.ts +0 -39
  83. package/src/lib/parse.test.ts +0 -75
  84. package/src/lib/parse.ts +0 -23
  85. package/src/lib/path.ts +0 -49
  86. package/src/lib/pipeline.ts +0 -17
  87. package/src/lib/types.ts +0 -34
  88. package/src/lib/walk.ts +0 -104
  89. package/src/runtime/cache/cache.ts +0 -1026
  90. package/src/runtime/cache/gc.ts +0 -56
  91. package/src/runtime/cache/index.ts +0 -3
  92. package/src/runtime/cache/lists.ts +0 -516
  93. package/src/runtime/cache/storage.ts +0 -574
  94. package/src/runtime/cache/stuff.ts +0 -77
  95. package/src/runtime/cache/subscription.ts +0 -329
  96. package/src/runtime/cache/tests/availability.test.ts +0 -408
  97. package/src/runtime/cache/tests/gc.test.ts +0 -319
  98. package/src/runtime/cache/tests/keys.test.ts +0 -36
  99. package/src/runtime/cache/tests/list.test.ts +0 -3854
  100. package/src/runtime/cache/tests/readwrite.test.ts +0 -1201
  101. package/src/runtime/cache/tests/scalars.test.ts +0 -218
  102. package/src/runtime/cache/tests/storage.test.ts +0 -426
  103. package/src/runtime/cache/tests/subscriptions.test.ts +0 -1757
  104. package/src/runtime/index.ts +0 -29
  105. package/src/runtime/lib/config.ts +0 -211
  106. package/src/runtime/lib/constants.ts +0 -17
  107. package/src/runtime/lib/deepEquals.ts +0 -32
  108. package/src/runtime/lib/errors.ts +0 -8
  109. package/src/runtime/lib/index.ts +0 -8
  110. package/src/runtime/lib/log.ts +0 -69
  111. package/src/runtime/lib/network.ts +0 -303
  112. package/src/runtime/lib/networkUtils.ts +0 -151
  113. package/src/runtime/lib/scalars.test.ts +0 -877
  114. package/src/runtime/lib/scalars.ts +0 -195
  115. package/src/runtime/lib/types.ts +0 -195
  116. package/src/test/index.ts +0 -294
  117. package/src/vite/ast.ts +0 -107
  118. package/src/vite/houdini.ts +0 -113
  119. package/src/vite/imports.ts +0 -129
  120. package/src/vite/index.ts +0 -55
  121. package/src/vite/schema.ts +0 -80
@@ -1,154 +0,0 @@
1
- import graphql, { Kind as GraphqlKinds } from 'graphql'
2
-
3
- import { Config, HoudiniError, CollectedGraphQLDocument } from '../../lib'
4
-
5
- export type FragmentDependency = {
6
- definition: graphql.FragmentDefinitionNode
7
- requiredFragments: string[]
8
- document: CollectedGraphQLDocument
9
- }
10
-
11
- // includeFragmentDefinitions adds any referenced fragments to operations
12
- export default async function includeFragmentDefinitions(
13
- config: Config,
14
- documents: CollectedGraphQLDocument[]
15
- ): Promise<void> {
16
- // we will need to add the same fragment definitions to multiple operations so lets compute
17
- // a single mapping that we'll reference later from the list of documents
18
- const fragments = collectFragments(config, documents)
19
-
20
- // visit every document and add any fragment definitions that are missing
21
- for (const [index, { name, document, filename }] of documents.entries()) {
22
- // look for the operation in this document
23
- const operation = document.definitions.find(
24
- ({ kind }) => kind === GraphqlKinds.OPERATION_DEFINITION
25
- ) as graphql.OperationDefinitionNode
26
-
27
- // if there isn't one we don't care about this document
28
- if (!operation) {
29
- continue
30
- }
31
-
32
- // grab the full list of required fragments
33
- const allFragments = flattenFragments(
34
- filename,
35
- { requiredFragments: findRequiredFragments(operation.selectionSet) },
36
- fragments
37
- )
38
-
39
- // add every required fragment to the document
40
- documents[index].document = {
41
- ...document,
42
- definitions: [
43
- operation,
44
- ...allFragments.map((fragmentName) => fragments[fragmentName].definition),
45
- ],
46
- }
47
- }
48
- }
49
-
50
- export function collectFragments(
51
- config: Config,
52
- docs: CollectedGraphQLDocument[]
53
- ): Record<string, FragmentDependency> {
54
- return docs.reduce<{ [name: string]: FragmentDependency }>((acc, doc) => {
55
- // look for any definitions in this document
56
- const definitions = doc.document.definitions.reduce(
57
- (prev, definition) =>
58
- definition.kind !== 'FragmentDefinition'
59
- ? prev
60
- : {
61
- ...prev,
62
- [definition.name.value]: {
63
- definition,
64
- requiredFragments: findRequiredFragments(definition.selectionSet),
65
- document: doc,
66
- },
67
- },
68
- {}
69
- )
70
-
71
- // add any definitions we found in this document
72
- return {
73
- ...acc,
74
- ...definitions,
75
- }
76
- }, {})
77
- }
78
-
79
- function findRequiredFragments(selectionSet: graphql.SelectionSetNode): Array<string> {
80
- // if there are no selections in this set
81
- if (selectionSet.selections.length === 0) {
82
- return []
83
- }
84
-
85
- // build up a list of referenced fragments in this selection
86
- const referencedFragments: string[] = []
87
- for (const selection of selectionSet.selections) {
88
- // if this selection is a fragment spread
89
- if (selection.kind === GraphqlKinds.FRAGMENT_SPREAD) {
90
- // add the name of the referenced fragment
91
- referencedFragments.push(selection.name.value)
92
- // if this is something with a subselection
93
- } else if (selection.selectionSet) {
94
- // add the referenced fragments in the selection
95
- referencedFragments.push(...findRequiredFragments(selection.selectionSet))
96
- }
97
- }
98
-
99
- // we're done
100
- return referencedFragments
101
- }
102
-
103
- // take a list of required fragments and turn it into a list of fragments
104
- // needed to create the query document
105
- function flattenFragments(
106
- filepath: string,
107
- operation: { requiredFragments: Array<string> },
108
- fragments: { [name: string]: { requiredFragments: Array<string> } }
109
- ): Array<string> {
110
- // the list of fragments to return
111
- const frags = new Set<string>()
112
-
113
- // we're going to do this breadth-first to avoid creating
114
- // duplicates. If we did this a depth-first we would process dependent
115
- // fragments after we check if we've already processed this node
116
-
117
- // the list of fragments we still have to process
118
- const remaining = [...operation.requiredFragments]
119
-
120
- // make sure we hit every node
121
- while (remaining.length > 0) {
122
- // grab the fragment we are going to add
123
- const nextFragment = remaining.shift()
124
-
125
- // make sure we got something
126
- if (!nextFragment) {
127
- continue
128
- }
129
-
130
- // if we haven't seen this fragment before we need to add it to the pile
131
- if (!frags.has(nextFragment)) {
132
- frags.add(nextFragment)
133
- }
134
- // we have seen this value already
135
- else {
136
- continue
137
- }
138
-
139
- // grab the referenced fragment
140
- const targetFragment = fragments[nextFragment]
141
- if (!targetFragment) {
142
- throw new HoudiniError({
143
- filepath,
144
- message: 'compose: could not find definition for fragment ' + nextFragment,
145
- })
146
- }
147
-
148
- // add this fragments dependents to the pile
149
- remaining.push(...targetFragment.requiredFragments)
150
- }
151
-
152
- // we're done
153
- return [...frags]
154
- }