MCPcopy
hub / github.com/tinacms/tinacms / generateTypes

Function generateTypes

packages/@tinacms/cli/src/next/codegen/codegen/index.ts:17–58  ·  view source on GitHub ↗
(
  schema: GraphQLSchema,
  queryPathGlob = process.cwd(),
  fragDocPath = process.cwd(),
  apiURL: string
)

Source from the content-addressed store, hash-verified

15import { plugin as typescriptSdkPlugin } from './sdkPlugin';
16
17export const generateTypes = async (
18 schema: GraphQLSchema,
19 queryPathGlob = process.cwd(),
20 fragDocPath = process.cwd(),
21 apiURL: string
22) => {
23 let docs = [];
24 let fragDocs = [];
25
26 docs = await loadGraphQLDocuments(queryPathGlob);
27 fragDocs = await loadGraphQLDocuments(fragDocPath);
28
29 // See https://www.graphql-code-generator.com/docs/getting-started/programmatic-usage for more details
30 const res = await codegen({
31 // Filename is not used. This is because the typescript plugin returns a string instead of writing to a file.
32 filename: process.cwd(),
33 schema: parse(printSchema(schema)),
34 documents: [...docs, ...fragDocs],
35 config: {},
36 plugins: [
37 { typescript: {} },
38 { typescriptOperations: {} },
39 {
40 typescriptSdk: {},
41 },
42 { AddGeneratedClient: {} },
43 ],
44 pluginMap: {
45 typescript: {
46 plugin: typescriptPlugin,
47 },
48 typescriptOperations: {
49 plugin: typescriptOperationsPlugin,
50 },
51 typescriptSdk: {
52 plugin: typescriptSdkPlugin,
53 },
54 AddGeneratedClient: AddGeneratedClient(apiURL),
55 },
56 });
57 return res;
58};
59
60const loadGraphQLDocuments = async (globPath: string) => {
61 let result = [];

Callers 1

genTypesMethod · 0.90

Calls 3

AddGeneratedClientFunction · 0.90
loadGraphQLDocumentsFunction · 0.85
parseFunction · 0.50

Tested by

no test coverage detected