protected function isValidScalar(ValueNodeInterface $node): void
    {
        $locationType = $this->context->getInputType();

        if (null === $locationType) {
            return;
        }

        $type = getNamedType($locationType);

        if (!($type instanceof ScalarType)) {
            $didYouMean = $this->getEnumTypeSuggestion($type, $node) ?? null;

            $this->context->reportError(
                new ValidationException(
                    badValueMessage((string)$locationType, printNode($node), $didYouMean),
                    [$node]
                )
            );

            return;
        }

        // Scalars determine if a literal value is valid via parseLiteral() which
        // may throw or return an invalid value to indicate failure.
        try {
            $result = $type->parseLiteral($node, null/* $variables */);

            if (null === $result) {
                $this->context->reportError(
                    new ValidationException(
                        badValueMessage((string)$locationType, printNode($node)),
                        [$node]
                    )
                );
            }
        } catch (\Exception $ex) {
            // Ensure a reference to the original error is maintained.
            $this->context->reportError(
                new ValidationException(
                    badValueMessage((string)$locationType, printNode($node), $ex->getMessage()),
                    [$node],
                    null,
                    null,
                    null,
                    null,
                    $ex
                )
            );
        }
    }