How to use the graphql-transformer-core function in graphql-transformer-core

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

github aws-amplify / amplify-cli / packages / graphql-relation-transformer / src / __tests__ / ModelRelationTransformer.tests.ts View on Github external
test('RelationTransformer should fail if relation was with an object that is not a Model type.', () => {
    const validSchema = `
    type Test @model {
        id: ID!
        email: String!
        testObj: Test1 @relation(fields: ["email"])
    }

    type Test1 {
        id: ID!
        name: String!
    }
    `

    const transformer = new GraphQLTransform({
        transformers: [
            new DynamoDBModelTransformer(),
            new RelationTransformer()
        ]
    })

    expect(() => transformer.transform(validSchema)).toThrowError(`Object type Test1 must be annotated with @model.`);
})
github aws-amplify / amplify-cli / packages / graphql-elasticsearch-transformer / src / run.ts View on Github external
import { AppSyncTransformer } from "graphql-appsync-transformer";

import fs = require('fs');

const validSchema = `
type Post @model @searchable {
    id: ID!
    title: String!
    upvotes: Int
    downvotes: Int
    percantageUp: Float
    comments: [String]
    isPublished: Boolean
}`;

const transformer = new GraphQLTransform({
    transformers: [
        new AppSyncTransformer(),
        new DynamoDBModelTransformer(),
        new SearchableModelTransformer()]
});
const out = transformer.transform(validSchema);
fs.writeFile('cf.out.json', JSON.stringify(out, null, 4), (err) => {
    if (err) {
        throw err;
    }
    console.log('SUCCESS!');
});
github aws-amplify / amplify-cli / packages / graphql-dynamodb-transformer / src / run.ts View on Github external
id: ID!
    title: String!
    upvotes: Int
    downvotes: Int
    percantageUp: Float
    comments: [String]
    isPublished: Boolean
}

type User @model {
    id: ID!
    name: String!
}
`;

const transformer = new GraphQLTransform({
    transformers: [
        new AppSyncTransformer(),
        new DynamoDBModelTransformer()
    ]
});
const out = transformer.transform(validSchema);
fs.writeFile('cf.out.json', JSON.stringify(out, null, 4), (err) => {
    if (err) {
        throw err;
    }
    console.log('SUCCESS!');
});