How to use the graphql-mapping-template.or function in graphql-mapping-template

To help you get started, we’ve selected a few graphql-mapping-template 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-auth-transformer / src / resources.ts View on Github external
public throwIfNotStaticGroupAuthorizedOrAuthConditionIsEmpty(field?: FieldDefinitionNode): Expression {
    const staticGroupAuthorizedVariable = this.getStaticAuthorizationVariable(field);
    const ifUnauthThrow = iff(
      not(parens(or([equals(ref(staticGroupAuthorizedVariable), raw('true')), parens(raw('$totalAuthExpression != ""'))]))),
      raw('$util.unauthorized()')
    );
    return block('Throw if unauthorized', [ifUnauthThrow]);
  }
github aws-amplify / amplify-cli / packages / graphql-http-transformer / src / resources.ts View on Github external
        or(nonNullArgs.map((arg: string) => parens(and([raw(`!$ctx.args.body.${arg}`), raw(`!$ctx.args.query.${arg}`)])))),
        ref('util.error("An argument you marked as Non-Null is not present ' + 'in the query nor the body of your request."))')
github aws-amplify / amplify-cli / packages / graphql-auth-transformer / src / resources.ts View on Github external
public throwIfSubscriptionUnauthorized(): Expression {
    const ifUnauthThrow = iff(
      not(
        parens(
          or([
            equals(ref(ResourceConstants.SNIPPETS.IsStaticGroupAuthorizedVariable), raw('true')),
            equals(ref(ResourceConstants.SNIPPETS.IsOwnerAuthorizedVariable), raw('true')),
          ])
        )
      ),
      raw('$util.unauthorized()')
    );
    return block('Throw if unauthorized', [ifUnauthThrow]);
  }
github aws-amplify / amplify-cli / packages / graphql-auth-transformer / src / resources.ts View on Github external
public throwIfUnauthorized(field?: FieldDefinitionNode): Expression {
    const staticGroupAuthorizedVariable = this.getStaticAuthorizationVariable(field);
    const ifUnauthThrow = iff(
      not(
        parens(
          or([
            equals(ref(staticGroupAuthorizedVariable), raw('true')),
            equals(ref(ResourceConstants.SNIPPETS.IsDynamicGroupAuthorizedVariable), raw('true')),
            equals(ref(ResourceConstants.SNIPPETS.IsOwnerAuthorizedVariable), raw('true')),
          ])
        )
      ),
      raw('$util.unauthorized()')
    );
    return block('Throw if unauthorized', [ifUnauthThrow]);
  }
github aws-amplify / amplify-cli / packages / graphql-auth-transformer / src / resources.ts View on Github external
public appendItemIfLocallyAuthorized(): Expression {
        return iff(
            parens(
                or([
                    equals(ref(ResourceConstants.SNIPPETS.IsLocalDynamicGroupAuthorizedVariable), raw('true')),
                    equals(ref(ResourceConstants.SNIPPETS.IsLocalOwnerAuthorizedVariable), raw('true'))
                ])
            ), qref('$items.add($item)')
        )
    }
github aws-amplify / amplify-cli / packages / graphql-auth-transformer / src / resources.ts View on Github external
public throwIfNotStaticGroupAuthorizedOrAuthConditionIsEmpty(): Expression {
        const ifUnauthThrow = iff(
            not(parens(
                or([
                    equals(ref(ResourceConstants.SNIPPETS.IsStaticGroupAuthorizedVariable), raw('true')),
                    parens(raw('$authCondition && $authCondition.expression != ""'))
                ])
            )), raw('$util.unauthorized()')
        )
        return block('Throw if unauthorized', [
            ifUnauthThrow,
        ])
    }
github aws-amplify / amplify-cli / packages / graphql-auth-transformer / src / resources.ts View on Github external
public throwIfUnauthorized(): Expression {
        const ifUnauthThrow = iff(
            not(parens(
                or([
                    equals(ref(ResourceConstants.SNIPPETS.IsStaticGroupAuthorizedVariable), raw('true')),
                    equals(ref(ResourceConstants.SNIPPETS.IsDynamicGroupAuthorizedVariable), raw('true')),
                    equals(ref(ResourceConstants.SNIPPETS.IsOwnerAuthorizedVariable), raw('true'))
                ])
            )), raw('$util.unauthorized()')
        )
        return block('Throw if unauthorized', [
            ifUnauthThrow,
        ])
    }
github aws-amplify / amplify-cli / packages / graphql-auth-transformer / src / resources.ts View on Github external
public appendItemIfLocallyAuthorized(): Expression {
    return iff(
      parens(
        or([
          equals(ref(ResourceConstants.SNIPPETS.IsLocalDynamicGroupAuthorizedVariable), raw('true')),
          equals(ref(ResourceConstants.SNIPPETS.IsLocalOwnerAuthorizedVariable), raw('true')),
        ])
      ),
      qref('$items.add($item)')
    );
  }