How to use the graphql-transformer-common.ResourceConstants.RESOURCES function in graphql-transformer-common

To help you get started, we’ve selected a few graphql-transformer-common 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 / graphql-transformer-core / src / util / amplifyUtils.ts View on Github external
const allResourceIds = Object.keys(rootStack.Resources).filter((k: string) => {
    const resource = rootStack.Resources[k];
    return resourceTypesToDependOn[resource.Type];
  });
  // Looping through the parameters defined by the transform (aka. rootStack)
  const parametersKeys = Object.keys(rootStack.Parameters);
  const customStackParams = parametersKeys.reduce(
    (acc: any, k: string) => ({
      ...acc,
      [k]: Fn.Ref(k),
    }),
    {}
  );
  // customStackParams is a map that will be passed as the "parameters" value
  // to any nested stacks.
  customStackParams[ResourceConstants.PARAMETERS.AppSyncApiId] = Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId');

  // Load the root stack's parameters as we will update them with the Child Stack's parameters
  // if they are not already present in the root stack.
  let updatedParameters = rootStack.Parameters;

  for (const userStack of Object.keys(userStacks)) {
    if (transformOutput.stacks[userStack]) {
      throw new Error(`You cannot provide a stack named ${userStack} as it \
            will be overwritten by a stack generated by the GraphQL Transform.`);
    }
    const userDefinedStack = userConfig.stacks[userStack];

    /**
     * First loop through the parameters in the user defined stack and see
     * if there are any Parameters that are present in the child but not the
     * root stack - if so, add it to the root stack.
github aws-amplify / amplify-cli / packages / graphql-transformer-core / src / util / syncUtils.ts View on Github external
export function syncLambdaIAMRole({ name, region }: { name: string; region?: string }) {
    return new IAM.Role({
      RoleName: Fn.If(
        ResourceConstants.CONDITIONS.HasEnvironmentParameter,
        Fn.Join('-', [
          name.slice(0, 26), // max of 64. 64-10-26-28 = 0
          Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'), // 26
          Fn.Ref(ResourceConstants.PARAMETERS.Env), // 10
        ]),
        Fn.Join('-', [
          // tslint:disable-next-line: no-magic-numbers
          name.slice(0, 37), // max of 64. 64-26-38 = 0
          Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'), // 26
        ])
      ),
      AssumeRolePolicyDocument: {
        Version: '2012-10-17',
        Statement: [
          {
            Effect: 'Allow',
            Principal: {
              Service: 'appsync.amazonaws.com',
            },
            Action: 'sts:AssumeRole',
          },
        ],
      },
      Policies: [
        {
github aws-amplify / amplify-cli / packages / graphql-function-transformer / src / FunctionTransformer.ts View on Github external
role = (name: string, region: string): any => {
    return new IAM.Role({
      RoleName: Fn.If(
        ResourceConstants.CONDITIONS.HasEnvironmentParameter,
        Fn.Join('-', [
          FunctionResourceIDs.FunctionIAMRoleName(name, true), // max of 64. 64-10-26-28 = 0
          Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'), // 26
          Fn.Ref(ResourceConstants.PARAMETERS.Env), // 10
        ]),
        Fn.Join('-', [
          FunctionResourceIDs.FunctionIAMRoleName(name, false), // max of 64. 64-26-38 = 0
          Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'), // 26
        ])
      ),
      AssumeRolePolicyDocument: {
        Version: '2012-10-17',
        Statement: [
          {
            Effect: 'Allow',
            Principal: {
              Service: 'appsync.amazonaws.com',
            },
            Action: 'sts:AssumeRole',
github aws-amplify / amplify-cli / packages / graphql-http-transformer / src / resources.ts View on Github external
public makeHttpDataSource(baseURL: string) {
    return new AppSync.DataSource({
      ApiId: Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'),
      Name: HttpResourceIDs.HttpDataSourceID(baseURL),
      Type: 'HTTP',
      HttpConfig: {
        Endpoint: this.replaceEnv(baseURL),
      },
    });
  }
github aws-amplify / amplify-cli / packages / graphql-connection-transformer / src / resources.ts View on Github external
DataSourceName: Fn.GetAtt(ModelResourceIDs.ModelTableDataSourceID(relatedType.name.value), 'Name'),
            FieldName: field,
            TypeName: type,
            RequestMappingTemplate: print(
                compoundExpression([
                    ...setup,
                    queryObj
                ])
            ),
            ResponseMappingTemplate: print(
                compoundExpression([
                    iff(raw('!$result'), set(ref('result'), ref('ctx.result'))),
                    raw('$util.toJson($result)')
                ])
            )
        }).dependsOn(ResourceConstants.RESOURCES.GraphQLSchemaLogicalID)
    }
github aws-amplify / amplify-cli / packages / graphql-elasticsearch-transformer / src / resources.ts View on Github external
private domainArn() {
        return Fn.GetAtt(
            ResourceConstants.RESOURCES.ElasticsearchDomainLogicalID,
            "DomainArn"
        )
    }
github aws-amplify / amplify-cli / packages / graphql-auth-transformer / src / resources.ts View on Github external
public makeApiKeyOutput(): any {
        return {
            Description: "Your GraphQL API key. Provide via 'x-api-key' header.",
            Value: Fn.GetAtt(ResourceConstants.RESOURCES.APIKeyLogicalID, 'ApiKey'),
            Export: {
                Name: Fn.Join(':', [Refs.StackName, "GraphQLApiKey"])
            },
            Condition: ResourceConstants.CONDITIONS.ShouldCreateAPIKey
        };
    }
github aws-amplify / amplify-cli / packages / graphql-dynamodb-transformer / src / resources.ts View on Github external
SyncResourceIDs.syncTableName,
                              Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'),
                            ])
                          ),
                        }),
                        Fn.Sub('arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${tablename}/*', {
                          tablename: Fn.If(
                            ResourceConstants.CONDITIONS.HasEnvironmentParameter,
                            Fn.Join('-', [
                              SyncResourceIDs.syncTableName,
                              Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'),
                              Fn.Ref(ResourceConstants.PARAMETERS.Env),
                            ]),
                            Fn.Join('-', [
                              SyncResourceIDs.syncTableName,
                              Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'),
                            ])
                          ),
                        }),
                      ]
                    : []),
                ],
              },
            ],
          },
        }),
        ...(syncConfig && SyncUtils.isLambdaSyncConfig(syncConfig)
          ? [SyncUtils.createSyncLambdaIAMPolicy(syncConfig.LambdaConflictHandler)]
          : []),
      ],
    });
  }
github aws-amplify / amplify-cli / packages / graphql-auth-transformer / src / resources.ts View on Github external
public makeApiKeyOutput(): any {
    return {
      Description: "Your GraphQL API key. Provide via 'x-api-key' header.",
      Value: Fn.GetAtt(ResourceConstants.RESOURCES.APIKeyLogicalID, 'ApiKey'),
      Export: {
        Name: Fn.Join(':', [Refs.StackName, 'GraphQLApiKey']),
      },
      Condition: ResourceConstants.CONDITIONS.ShouldCreateAPIKey,
    };
  }
github aws-amplify / amplify-cli / packages / graphql-transformer-core / src / TransformFormatter.ts View on Github external
private buildAndSetSchema(ctx: TransformerContext): string {
    const SDL = this.buildSchema(ctx);
    const schemaResource = this.schemaResourceUtil.makeAppSyncSchema();
    ctx.setResource(ResourceConstants.RESOURCES.GraphQLSchemaLogicalID, schemaResource);
    return SDL;
  }