How to use the graphql-auth-transformer.ModelAuthTransformer function in graphql-auth-transformer

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;
  };
}

graphql-auth-transformer

Implements the @auth directive for the appsync model transform.

Apache-2.0
Latest version published 3 months ago

Package Health Score

89 / 100
Full package analysis