-
Notifications
You must be signed in to change notification settings - Fork 463
Expand file tree
/
Copy pathgetOperationManifestFromProject.ts
More file actions
45 lines (41 loc) · 1.13 KB
/
getOperationManifestFromProject.ts
File metadata and controls
45 lines (41 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { GraphQLClientProject } from "apollo-language-server";
import {
defaultOperationRegistrySignature,
operationHash
} from "apollo-graphql";
export interface ManifestEntry {
signature: string;
document: string;
metadata: {
engineSignature: string;
};
}
export function getOperationManifestFromProject(
project: GraphQLClientProject,
options: { preserveStringAndNumericLiterals: boolean } = {
preserveStringAndNumericLiterals: false
}
): ManifestEntry[] {
const manifest = Object.entries(
project.mergedOperationsAndFragmentsForService
).map(([operationName, operationAST]) => {
const printed = defaultOperationRegistrySignature(
operationAST,
operationName,
{
preserveStringAndNumericLiterals:
options.preserveStringAndNumericLiterals
}
);
return {
signature: operationHash(printed),
document: printed,
// TODO: unused. Remove or repurpose this field altogether with op. registry 2.0 work.
// For now, this field is non-nullable on the input type.
metadata: {
engineSignature: ""
}
};
});
return manifest;
}