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.
- package/README.md +33 -0
- package/build/cmd-cjs/index.js +2 -2
- package/build/cmd-esm/index.js +2 -2
- package/package.json +16 -1
- package/.turbo/turbo-compile.log +0 -5
- package/.turbo/turbo-typedefs.log +0 -5
- package/CHANGELOG.md +0 -377
- package/src/cmd/generate.ts +0 -54
- package/src/cmd/index.ts +0 -60
- package/src/cmd/init.ts +0 -637
- package/src/cmd/pullSchema.ts +0 -40
- package/src/codegen/generators/artifacts/artifacts.test.ts +0 -3246
- package/src/codegen/generators/artifacts/fieldKey.ts +0 -60
- package/src/codegen/generators/artifacts/index.ts +0 -330
- package/src/codegen/generators/artifacts/indexFile.ts +0 -24
- package/src/codegen/generators/artifacts/inputs.ts +0 -81
- package/src/codegen/generators/artifacts/operations.ts +0 -281
- package/src/codegen/generators/artifacts/pagination.test.ts +0 -664
- package/src/codegen/generators/artifacts/policy.test.ts +0 -298
- package/src/codegen/generators/artifacts/selection.ts +0 -208
- package/src/codegen/generators/artifacts/utils.test.ts +0 -118
- package/src/codegen/generators/artifacts/utils.ts +0 -108
- package/src/codegen/generators/definitions/enums.test.ts +0 -61
- package/src/codegen/generators/definitions/enums.ts +0 -68
- package/src/codegen/generators/definitions/index.ts +0 -11
- package/src/codegen/generators/definitions/schema.test.ts +0 -236
- package/src/codegen/generators/index.ts +0 -6
- package/src/codegen/generators/indexFile/index.ts +0 -63
- package/src/codegen/generators/indexFile/indexFile.test.ts +0 -72
- package/src/codegen/generators/persistedQueries/index.ts +0 -55
- package/src/codegen/generators/persistedQueries/persistedQuery.test.ts +0 -26
- package/src/codegen/generators/runtime/index.test.ts +0 -74
- package/src/codegen/generators/runtime/index.ts +0 -64
- package/src/codegen/generators/runtime/runtime.test.ts +0 -25
- package/src/codegen/generators/typescript/addReferencedInputTypes.ts +0 -77
- package/src/codegen/generators/typescript/index.ts +0 -412
- package/src/codegen/generators/typescript/inlineType.ts +0 -409
- package/src/codegen/generators/typescript/typeReference.ts +0 -44
- package/src/codegen/generators/typescript/types.ts +0 -81
- package/src/codegen/generators/typescript/typescript.test.ts +0 -1434
- package/src/codegen/index.ts +0 -406
- package/src/codegen/transforms/addID.test.ts +0 -93
- package/src/codegen/transforms/addID.ts +0 -86
- package/src/codegen/transforms/composeQueries.test.ts +0 -50
- package/src/codegen/transforms/composeQueries.ts +0 -154
- package/src/codegen/transforms/fragmentVariables.test.ts +0 -636
- package/src/codegen/transforms/fragmentVariables.ts +0 -417
- package/src/codegen/transforms/index.ts +0 -7
- package/src/codegen/transforms/list.ts +0 -484
- package/src/codegen/transforms/lists.test.ts +0 -530
- package/src/codegen/transforms/paginate.test.ts +0 -1528
- package/src/codegen/transforms/paginate.ts +0 -770
- package/src/codegen/transforms/schema.test.ts +0 -136
- package/src/codegen/transforms/schema.ts +0 -109
- package/src/codegen/transforms/typename.test.ts +0 -125
- package/src/codegen/transforms/typename.ts +0 -55
- package/src/codegen/utils/commonjs.ts +0 -26
- package/src/codegen/utils/flattenSelections.ts +0 -179
- package/src/codegen/utils/graphql.test.ts +0 -35
- package/src/codegen/utils/graphql.ts +0 -79
- package/src/codegen/utils/index.ts +0 -5
- package/src/codegen/utils/moduleExport.ts +0 -27
- package/src/codegen/utils/murmur.ts +0 -79
- package/src/codegen/validators/index.ts +0 -4
- package/src/codegen/validators/noIDAlias.test.ts +0 -71
- package/src/codegen/validators/noIDAlias.ts +0 -39
- package/src/codegen/validators/plugins.ts +0 -25
- package/src/codegen/validators/typeCheck.test.ts +0 -960
- package/src/codegen/validators/typeCheck.ts +0 -1086
- package/src/codegen/validators/uniqueNames.test.ts +0 -59
- package/src/codegen/validators/uniqueNames.ts +0 -39
- package/src/lib/cleanupFiles.ts +0 -20
- package/src/lib/config.test.ts +0 -13
- package/src/lib/config.ts +0 -954
- package/src/lib/constants.ts +0 -11
- package/src/lib/error.ts +0 -24
- package/src/lib/fs.ts +0 -285
- package/src/lib/graphql.test.ts +0 -211
- package/src/lib/graphql.ts +0 -200
- package/src/lib/imports.ts +0 -82
- package/src/lib/index.ts +0 -17
- package/src/lib/introspection.ts +0 -39
- package/src/lib/parse.test.ts +0 -75
- package/src/lib/parse.ts +0 -23
- package/src/lib/path.ts +0 -49
- package/src/lib/pipeline.ts +0 -17
- package/src/lib/types.ts +0 -34
- package/src/lib/walk.ts +0 -104
- package/src/runtime/cache/cache.ts +0 -1026
- package/src/runtime/cache/gc.ts +0 -56
- package/src/runtime/cache/index.ts +0 -3
- package/src/runtime/cache/lists.ts +0 -516
- package/src/runtime/cache/storage.ts +0 -574
- package/src/runtime/cache/stuff.ts +0 -77
- package/src/runtime/cache/subscription.ts +0 -329
- package/src/runtime/cache/tests/availability.test.ts +0 -408
- package/src/runtime/cache/tests/gc.test.ts +0 -319
- package/src/runtime/cache/tests/keys.test.ts +0 -36
- package/src/runtime/cache/tests/list.test.ts +0 -3854
- package/src/runtime/cache/tests/readwrite.test.ts +0 -1201
- package/src/runtime/cache/tests/scalars.test.ts +0 -218
- package/src/runtime/cache/tests/storage.test.ts +0 -426
- package/src/runtime/cache/tests/subscriptions.test.ts +0 -1757
- package/src/runtime/index.ts +0 -29
- package/src/runtime/lib/config.ts +0 -211
- package/src/runtime/lib/constants.ts +0 -17
- package/src/runtime/lib/deepEquals.ts +0 -32
- package/src/runtime/lib/errors.ts +0 -8
- package/src/runtime/lib/index.ts +0 -8
- package/src/runtime/lib/log.ts +0 -69
- package/src/runtime/lib/network.ts +0 -303
- package/src/runtime/lib/networkUtils.ts +0 -151
- package/src/runtime/lib/scalars.test.ts +0 -877
- package/src/runtime/lib/scalars.ts +0 -195
- package/src/runtime/lib/types.ts +0 -195
- package/src/test/index.ts +0 -294
- package/src/vite/ast.ts +0 -107
- package/src/vite/houdini.ts +0 -113
- package/src/vite/imports.ts +0 -129
- package/src/vite/index.ts +0 -55
- 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
|
-
}
|