How to use the graphql-relational-schema-transformer.RelationalDBTemplateGenerator function in graphql-relational-schema-transformer

To help you get started, we’ve selected a few graphql-relational-schema-transformer 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 aws-amplify / amplify-cli / packages / amplify-category-api / commands / api / add-graphql-datasource.js View on Github external
fs.ensureFileSync(graphqlSchemaFilePath);
        const graphqlSchemaRaw = fs.readFileSync(graphqlSchemaFilePath, 'utf8');
        const currGraphQLSchemaDoc = graphql.parse(graphqlSchemaRaw);

        const rdsGraphQLSchemaDoc = graphqlSchemaContext.schemaDoc;

        const concatGraphQLSchemaDoc = mergeTypes([currGraphQLSchemaDoc, rdsGraphQLSchemaDoc], { all: true });

        fs.writeFileSync(graphqlSchemaFilePath, concatGraphQLSchemaDoc, 'utf8');
        const resolversDir = `${projectBackendDirPath}/${category}/${resourceName}/resolvers`;

        /**
         * Instantiate a new Relational Template Generator and create
         * the template and relational resolvers
         */
        const templateGenerator = new RelationalDBTemplateGenerator(graphqlSchemaContext);
        context[rdsResourceName] = resourceName;
        context[rdsDatasource] = datasource;
        let template = templateGenerator.createTemplate(context);
        template = templateGenerator.addRelationalResolvers(template, resolversDir);
        const cfn = templateGenerator.printCloudformationTemplate(template);

        /**
         * Add the generated the CFN to the appropriate nested stacks directory
         */
        const stacksDir = `${projectBackendDirPath}/${category}/${resourceName}/stacks`;
        const writeToPath = `${stacksDir}/${resourceName}-${databaseName}-rds.json`;
        fs.writeFileSync(writeToPath, cfn, 'utf8');

        return datasource;
      })
      .then(datasourceName => {

graphql-relational-schema-transformer

An AppSync model transform that takes a relational database and turns that into a GraphQL API.

Apache-2.0
Latest version published 6 months ago

Package Health Score

89 / 100
Full package analysis