houdini 0.17.9 → 0.17.11
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,79 +0,0 @@
|
|
|
1
|
-
import * as graphql from 'graphql'
|
|
2
|
-
|
|
3
|
-
import { Config } from '../../lib'
|
|
4
|
-
|
|
5
|
-
export function unwrapType(
|
|
6
|
-
config: Config,
|
|
7
|
-
type: any,
|
|
8
|
-
wrappers: TypeWrapper[] = []
|
|
9
|
-
): { type: graphql.GraphQLNamedType; wrappers: TypeWrapper[] } {
|
|
10
|
-
// if we are looking at a non null type
|
|
11
|
-
if (type.kind === 'NonNullType') {
|
|
12
|
-
return unwrapType(config, type.type, [TypeWrapper.NonNull, ...wrappers])
|
|
13
|
-
}
|
|
14
|
-
if (type instanceof graphql.GraphQLNonNull) {
|
|
15
|
-
return unwrapType(config, type.ofType, [TypeWrapper.NonNull, ...wrappers])
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// if the last thing we added was not a non-null indicator
|
|
19
|
-
if (wrappers[0] !== TypeWrapper.NonNull) {
|
|
20
|
-
// add the nullable mark
|
|
21
|
-
wrappers.unshift(TypeWrapper.Nullable)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (type.kind === 'ListType') {
|
|
25
|
-
return unwrapType(config, type.type, [TypeWrapper.List, ...wrappers])
|
|
26
|
-
}
|
|
27
|
-
if (type instanceof graphql.GraphQLList) {
|
|
28
|
-
return unwrapType(config, type.ofType, [TypeWrapper.List, ...wrappers])
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// get the named type
|
|
32
|
-
const namedType = config.schema.getType(type.name.value || type.name)
|
|
33
|
-
if (!namedType) {
|
|
34
|
-
throw new Error('Could not unwrap type: ' + JSON.stringify(type))
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// don't add any wrappers
|
|
38
|
-
return { type: namedType, wrappers }
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function wrapType({
|
|
42
|
-
type,
|
|
43
|
-
wrappers,
|
|
44
|
-
}: {
|
|
45
|
-
type: graphql.GraphQLNamedType
|
|
46
|
-
wrappers: TypeWrapper[]
|
|
47
|
-
}): graphql.TypeNode {
|
|
48
|
-
const head = wrappers[0]
|
|
49
|
-
const tail = wrappers.slice(1)
|
|
50
|
-
|
|
51
|
-
let kind: graphql.TypeNode['kind'] = graphql.Kind.NAMED_TYPE
|
|
52
|
-
if (head === TypeWrapper.List) {
|
|
53
|
-
kind = graphql.Kind.LIST_TYPE
|
|
54
|
-
} else if (head === TypeWrapper.NonNull) {
|
|
55
|
-
kind = graphql.Kind.NON_NULL_TYPE
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (kind === 'NamedType') {
|
|
59
|
-
return {
|
|
60
|
-
kind,
|
|
61
|
-
name: {
|
|
62
|
-
kind: graphql.Kind.NAME,
|
|
63
|
-
value: type.name,
|
|
64
|
-
},
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
kind,
|
|
70
|
-
// @ts-ignore
|
|
71
|
-
type: wrapType({ type, wrappers: tail }),
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export enum TypeWrapper {
|
|
76
|
-
Nullable = 'Nullable',
|
|
77
|
-
List = 'List',
|
|
78
|
-
NonNull = 'NonNull',
|
|
79
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { ExpressionKind } from 'ast-types/gen/kinds'
|
|
2
|
-
import * as recast from 'recast'
|
|
3
|
-
|
|
4
|
-
import { Config } from '../../lib'
|
|
5
|
-
|
|
6
|
-
const AST = recast.types.builders
|
|
7
|
-
|
|
8
|
-
export function moduleExport(config: Config, key: string, value: ExpressionKind) {
|
|
9
|
-
// make sure we use valid commonjs if necessary
|
|
10
|
-
if (config.module === 'commonjs') {
|
|
11
|
-
// the thing to assign
|
|
12
|
-
let target = AST.memberExpression(AST.identifier('module'), AST.identifier('exports'))
|
|
13
|
-
if (key !== 'default') {
|
|
14
|
-
target = AST.memberExpression(target, AST.identifier(key))
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return AST.expressionStatement(AST.assignmentExpression('=', target, value))
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return key === 'default'
|
|
21
|
-
? AST.exportDefaultDeclaration(value)
|
|
22
|
-
: AST.exportNamedDeclaration(
|
|
23
|
-
AST.variableDeclaration('const', [
|
|
24
|
-
AST.variableDeclarator(AST.identifier(key), value),
|
|
25
|
-
])
|
|
26
|
-
)
|
|
27
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Based on implementations by Gary Court and Austin Appleby, 2011, MIT. Copied from https://github.com/facebook/relay
|
|
3
|
-
* @preserve-header
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
'use strict'
|
|
7
|
-
|
|
8
|
-
const BASE62 = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @param {string} key A UTF-16 or ASCII string
|
|
12
|
-
* @return {string} a base62 murmur hash
|
|
13
|
-
*/
|
|
14
|
-
export function murmurHash(str: string): string {
|
|
15
|
-
const length = str.length
|
|
16
|
-
const rem = length & 3
|
|
17
|
-
const len = length ^ rem
|
|
18
|
-
|
|
19
|
-
let h = 0
|
|
20
|
-
let i = 0
|
|
21
|
-
let k
|
|
22
|
-
|
|
23
|
-
while (i !== len) {
|
|
24
|
-
const ch4 = str.charCodeAt(i + 3)
|
|
25
|
-
|
|
26
|
-
k =
|
|
27
|
-
str.charCodeAt(i) ^
|
|
28
|
-
(str.charCodeAt(i + 1) << 8) ^
|
|
29
|
-
(str.charCodeAt(i + 2) << 16) ^
|
|
30
|
-
((ch4 & 0xff) << 24) ^
|
|
31
|
-
((ch4 & 0xff00) >> 8)
|
|
32
|
-
|
|
33
|
-
i += 4
|
|
34
|
-
|
|
35
|
-
k = (k * 0x2d51 + (k & 0xffff) * 0xcc9e0000) >>> 0
|
|
36
|
-
k = (k << 15) | (k >>> 17)
|
|
37
|
-
k = (k * 0x3593 + (k & 0xffff) * 0x1b870000) >>> 0
|
|
38
|
-
h ^= k
|
|
39
|
-
h = (h << 13) | (h >>> 19)
|
|
40
|
-
h = (h * 5 + 0xe6546b64) >>> 0
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
k = 0
|
|
44
|
-
switch (rem) {
|
|
45
|
-
/* eslint-disable no-fallthrough */
|
|
46
|
-
case 3:
|
|
47
|
-
k ^= str.charCodeAt(len + 2) << 16
|
|
48
|
-
case 2:
|
|
49
|
-
k ^= str.charCodeAt(len + 1) << 8
|
|
50
|
-
case 1:
|
|
51
|
-
k ^= str.charCodeAt(len)
|
|
52
|
-
|
|
53
|
-
k = (k * 0x2d51 + (k & 0xffff) * 0xcc9e0000) >>> 0
|
|
54
|
-
k = (k << 15) | (k >>> 17)
|
|
55
|
-
k = (k * 0x3593 + (k & 0xffff) * 0x1b870000) >>> 0
|
|
56
|
-
h ^= k
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
h ^= length
|
|
60
|
-
h ^= h >>> 16
|
|
61
|
-
h = (h * 0xca6b + (h & 0xffff) * 0x85eb0000) >>> 0
|
|
62
|
-
h ^= h >>> 13
|
|
63
|
-
h = (h * 0xae35 + (h & 0xffff) * 0xc2b20000) >>> 0
|
|
64
|
-
h ^= h >>> 16
|
|
65
|
-
|
|
66
|
-
h >>>= 0
|
|
67
|
-
|
|
68
|
-
if (!h) {
|
|
69
|
-
return '0'
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
let s = ''
|
|
73
|
-
while (h) {
|
|
74
|
-
const d = h % 62
|
|
75
|
-
s = BASE62[d] + s
|
|
76
|
-
h = (h - d) / 62
|
|
77
|
-
}
|
|
78
|
-
return s
|
|
79
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { test } from 'vitest'
|
|
2
|
-
|
|
3
|
-
import { CollectedGraphQLDocument } from '../../lib/types'
|
|
4
|
-
import { pipelineTest, testConfig } from '../../test'
|
|
5
|
-
|
|
6
|
-
const table: Row[] = [
|
|
7
|
-
{
|
|
8
|
-
title: 'allows non-alias ids',
|
|
9
|
-
pass: true,
|
|
10
|
-
documents: [
|
|
11
|
-
`
|
|
12
|
-
query QueryA {
|
|
13
|
-
user {
|
|
14
|
-
id
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
`,
|
|
18
|
-
],
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
title: 'fail if id alias is encountered',
|
|
22
|
-
pass: false,
|
|
23
|
-
documents: [
|
|
24
|
-
`
|
|
25
|
-
query QueryA {
|
|
26
|
-
user {
|
|
27
|
-
id: firstName
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
`,
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
title: 'check types with multiple ids',
|
|
35
|
-
pass: false,
|
|
36
|
-
documents: [
|
|
37
|
-
`
|
|
38
|
-
query QueryA {
|
|
39
|
-
ghost {
|
|
40
|
-
name: believers {
|
|
41
|
-
id
|
|
42
|
-
}
|
|
43
|
-
aka: friends {
|
|
44
|
-
name
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
`,
|
|
49
|
-
],
|
|
50
|
-
},
|
|
51
|
-
]
|
|
52
|
-
|
|
53
|
-
type Row =
|
|
54
|
-
| {
|
|
55
|
-
title: string
|
|
56
|
-
pass: true
|
|
57
|
-
documents: string[]
|
|
58
|
-
check?: (docs: CollectedGraphQLDocument[]) => void
|
|
59
|
-
}
|
|
60
|
-
| {
|
|
61
|
-
title: string
|
|
62
|
-
pass: false
|
|
63
|
-
documents: string[]
|
|
64
|
-
check?: (result: Error | Error[]) => void
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// run the tests
|
|
68
|
-
for (const { title, pass, documents, check } of table) {
|
|
69
|
-
// run the pipeline over the documents
|
|
70
|
-
test(title, pipelineTest(testConfig(), documents, pass, check))
|
|
71
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import * as graphql from 'graphql'
|
|
2
|
-
|
|
3
|
-
import { Config, parentTypeFromAncestors, HoudiniError, CollectedGraphQLDocument } from '../../lib'
|
|
4
|
-
|
|
5
|
-
// noIDAlias verifies that the user did not alias any field as id which would conflict
|
|
6
|
-
//with the runtime's cache invalidation strategy
|
|
7
|
-
export default async function noIDAlias(
|
|
8
|
-
config: Config,
|
|
9
|
-
docs: CollectedGraphQLDocument[]
|
|
10
|
-
): Promise<void> {
|
|
11
|
-
// collect the errors
|
|
12
|
-
const errors: Error[] = []
|
|
13
|
-
|
|
14
|
-
for (const { filename, document } of docs) {
|
|
15
|
-
graphql.visit(document, {
|
|
16
|
-
Field(node, _, __, ___, ancestors) {
|
|
17
|
-
const fieldType = parentTypeFromAncestors(config.schema, filename, ancestors).name
|
|
18
|
-
|
|
19
|
-
// if there is an alias on the node
|
|
20
|
-
if (config.keyFieldsForType(fieldType).includes(node.alias?.value || '')) {
|
|
21
|
-
errors.push(
|
|
22
|
-
new HoudiniError({
|
|
23
|
-
filepath: filename,
|
|
24
|
-
message: 'Encountered field with an alias that overwrites an id field',
|
|
25
|
-
})
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// if we got errors
|
|
33
|
-
if (errors.length > 0) {
|
|
34
|
-
throw errors
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// we're done here
|
|
38
|
-
return
|
|
39
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { Config } from '../../lib/config'
|
|
2
|
-
import type { CollectedGraphQLDocument } from '../../lib/types'
|
|
3
|
-
|
|
4
|
-
export default async function validatePlugins(
|
|
5
|
-
config: Config,
|
|
6
|
-
documents: CollectedGraphQLDocument[]
|
|
7
|
-
) {
|
|
8
|
-
let errors: unknown[] = []
|
|
9
|
-
|
|
10
|
-
for (const plugin of config.plugins) {
|
|
11
|
-
if (!plugin.validate) {
|
|
12
|
-
continue
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
await plugin.validate({ config, documents })
|
|
17
|
-
} catch (err) {
|
|
18
|
-
errors.push(err)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (errors.length > 0) {
|
|
23
|
-
throw errors
|
|
24
|
-
}
|
|
25
|
-
}
|