How to use graphql-auth-transformer - 5 common examples

To help you get started, we’ve selected a few graphql-auth-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 trek10inc / appsync-cloudformation-transformer-cli / src / index.js View on Github external
new DynamoDBModelTransformer(),
    new ModelConnectionTransformer(),
    new VersionedModelTransformer(),
    new DefaultValueTransformer()
]

// Only insert certain plugins if needed, otherwise they pollute the cloudformation
// for no good reason.
// We determine if needed with a simple string search for the directive string
function conditionalInsertDirectivePlugin(plugin, searchString){
    if (schema.indexOf(searchString) >= 0) {
        transformers.push(plugin)
    }
}

conditionalInsertDirectivePlugin(new ModelAuthTransformer(), '@auth');
conditionalInsertDirectivePlugin(new SearchableModelTransformer(), '@searchable');

// console.log(process.argv)
const transformer = new GraphQLTransform({
    transformers: transformers
})

const cfdoc = transformer.transform(schema);
console.log(JSON.stringify(cfdoc, null, 2))
github aws-amplify / amplify-cli / packages / amplify-provider-awscloudformation / lib / transform-graphql-schema.js View on Github external
return new CustomTransformer();
        } else if (typeof CustomTransformer === 'object') {
          return CustomTransformer;
        }

        throw new Error("Custom Transformers' default export must be a function or an object");
      })
      .filter(customTransformer => customTransformer);

    if (customTransformers.length > 0) {
      transformerList.push(...customTransformers);
    }

    // TODO: Build dependency mechanism into transformers. Auth runs last
    // so any resolvers that need to be protected will already be created.
    transformerList.push(new ModelAuthTransformer({ authConfig }));

    return transformerList;
  };
}
github aws-amplify / amplify-cli / packages / graphql-transform-cli / src / commands / create.ts View on Github external
description: 'The name of the application',
            required: true,
        })
        name: string,
        @param({
            description: 'The region to launch the stack in. Defaults to us-west-2',
            required: false,
            default: 'us-west-2'
        })
        region: string
    ) {
        const transformer = new GraphQLTransform({
            transformers: [
                new AppSyncTransformer(),
                new DynamoDBTransformer(),
                new AuthTransformer()
            ]
        })
        const cfdoc = transformer.transform(schema.readSync());
        const out = await createStack(cfdoc, name, region)
        return 'Application creation successfully started. It may take a few minutes to finish.'
    }
}
github aws-amplify / amplify-cli / packages / graphql-transform-cli / src / commands / update.ts View on Github external
description: 'The name of the application',
            required: true,
        })
        name: string,
        @param({
            description: 'The region to launch the stack in. Defaults to us-west-2',
            required: false,
            default: 'us-west-2'
        })
        region: string
    ) {
        const transformer = new GraphQLTransform({
            transformers: [
                new AppSyncTransformer(),
                new DynamoDBTransformer(),
                new AuthTransformer()
            ]
        })
        const cfdoc = transformer.transform(schema.readSync());
        const out = await updateStack(cfdoc, name, region)
        return 'Application update successfully started. It may take a few minutes to finish.'
    }
}
github aws-amplify / amplify-cli / packages / graphql-transform-cli / lib / commands / compile.js View on Github external
execute(schemaFile, output) {
        const transformer = new graphql_transform_1.default({
            transformers: [
                new graphql_appsync_transformer_1.default(),
                new graphql_dynamodb_transformer_1.default(),
                new graphql_auth_transformer_1.default()
            ]
        });
        const cfdoc = transformer.transform(schemaFile.readSync());
        output.writeSync(JSON.stringify(cfdoc, null, 4));
    }
};

graphql-auth-transformer

Implements the @auth directive for the appsync model transform.

Apache-2.0
Latest version published 24 days ago

Package Health Score

93 / 100
Full package analysis