floci-io/floci · error · CoercingParseLiteralException

AWSBoolean must be a boolean literal

Error message

AWSBoolean must be a boolean literal

What it means

Thrown by the AWSBoolean scalar's parseLiteral when the value written inline in the query document is not a BooleanValue literal. GraphQL's literal grammar distinguishes true/false keywords from quoted strings and numbers; only the bare keywords satisfy this scalar.

Source

Thrown at src/main/java/io/github/hectorvent/floci/services/appsync/graphql/scalars/AppSyncScalars.java:287

    public static final GraphQLScalarType AWS_BOOLEAN = GraphQLScalarType.newScalar()
        .name("AWSBoolean")
        .description("A boolean value")
        .coercing(new Coercing<Boolean, Boolean>() {
            @Override
            public Boolean serialize(Object dataFetcherResult) {
                if (dataFetcherResult == null) return null;
                if (dataFetcherResult instanceof Boolean b) return b;
                throw new CoercingSerializeException("AWSBoolean cannot serialize non-boolean value: " + dataFetcherResult.getClass().getSimpleName());
            }
            @Override
            public Boolean parseValue(Object input) {
                if (input instanceof Boolean b) return b;
                throw new CoercingParseValueException("AWSBoolean cannot parse non-boolean value: " + input);
            }
            @Override
            public Boolean parseLiteral(Object input) {
                if (input instanceof graphql.language.BooleanValue bv) return bv.isValue();
                throw new CoercingParseLiteralException("AWSBoolean must be a boolean literal");
            }
        })
        .build();

    public static final GraphQLScalarType AWS_LONG = GraphQLScalarType.newScalar()
        .name("AWSLong")
        .description("A 64-bit signed integer")
        .coercing(new Coercing<Long, Long>() {
            @Override
            public Long serialize(Object dataFetcherResult) {
                if (dataFetcherResult == null) return null;
                if (dataFetcherResult instanceof Number n) return n.longValue();
                return Long.parseLong(dataFetcherResult.toString());
            }
            @Override
            public Long parseValue(Object input) {
                if (input instanceof Number n) return n.longValue();
                return Long.parseLong(input.toString());

View on GitHub (pinned to 62ff490619)

Solutions

  1. Write the bare literal: flag: true or flag: false — no quotes
  2. Prefer passing the value as a $variable of type AWSBoolean over inline literals
  3. Fix query-builder templates so booleans bypass the quoting path
  4. Lint generated documents: AWSBoolean arguments must be true/false keywords

Example fix

# before
mutation { enable(flag: "true") }

# after
mutation Enable($flag: AWSBoolean!) { enable(flag: $flag) }
# variables: {"flag": true}
Defensive patterns

Strategy: type-guard

Validate before calling

// Document generation: render booleans unquoted
String literal = String.valueOf(b); // yields true/false keywords

Type guard

const rendersAsBooleanLiteral = (v: unknown): boolean => typeof v === 'boolean';

Try / catch

catch (CoercingParseLiteralException e) { // rewrite document: true/false without quotes, or move to a $variable }

Prevention

When it happens

Trigger: A query document contains enable(flag: "true"), enable(flag: 1), or enable(flag: True) (capitalized) instead of enable(flag: true).

Common situations: Query string builders that quote all interpolations; porting JSON examples directly into query documents (JSON habits: quoting booleans); typos in hand-written documents (True/FALSE); codegen templates rendering booleans as strings.

Related errors


AI-assisted analysis of floci-io/floci@62ff490619 (2026-08-14). Data as JSON: /api/errors/ab445dc455e8b28d. Report an issue: GitHub.