How to use the graphql-schema-typescript.generateTSTypesAsString function in graphql-schema-typescript

To help you get started, we’ve selected a few graphql-schema-typescript examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coralproject / talk / scripts / generateSchemaTypes.js View on Github external
},
    },
  ];

  for (const file of files) {
    // Load the graph schema.
    const schema = projects[file.name].getSchema();

    // Create the generated directory.
    const dir = path.dirname(file.fileName);
    if (!fs.existsSync(dir)) {
      fs.mkdirSync(dir);
    }

    // Create the types for this file.
    const types = await generateTSTypesAsString(schema, {
      tabSpaces: 2,
      typePrefix: "GQL",
      strictNulls: false,
      ...file.config,
    });

    fs.writeFileSync(file.fileName, types);
  }

  return files;
}

graphql-schema-typescript

Generate TypeScript from GraphQL's schema type definitions

MIT
Latest version published 1 year ago

Package Health Score

61 / 100
Full package analysis