Coder Social home page Coder Social logo

Comments (5)

Zerquix18 avatar Zerquix18 commented on June 9, 2024 2

So what fixed the issue in my case was to escape the value with:

$util.escapeJavaScript()

eg:

"$util.escapeJavaScript($ctx.args.long_description)"

from aws-mobile-appsync-events-starter-react.

ceich avatar ceich commented on June 9, 2024

When I edit an event in DynamoDB console to have a newline in the description, it properly shows as \n in the console, but the app displays it as a space.

from aws-mobile-appsync-events-starter-react.

ceich avatar ceich commented on June 9, 2024

A simple fix would be to escape() before creating and unescape() before displaying, but the job of satisfying DynamoDB's need for valid JSON seems to belong to the GraphQL layer or the Resolver.

from aws-mobile-appsync-events-starter-react.

mikeparisstuff avatar mikeparisstuff commented on June 9, 2024

Ah, I see what you mean. This is a limitation of the request mapping template currently as the result of the evaluated template is expected to be a JSON object that will be used to configure the call to DynamoDB. You can currently pass mutli-line strings through to dynamodb by referencing an argument on the context.

For example if you had this:

{
    "version": "2017-02-28",
    "operation": "PutItem",
    "key": {
        "id": { "S": "5f7a4c6d-eee0-474a-b4ca-2b52e953a8bf"}
    },
    "attributeValues": {
        "name": { "S": "one" },
        "where": { "S": "two" },
        "when": { "S": "2018-02-23T00:15:00Z" },
        "description": { "S": "$ctx.args.description" }
    }
}

You can pass a description with newlines as you might expect. I'll take a note of this and look into the possibility of escaping the evaluated template. Thanks for the feedback!

from aws-mobile-appsync-events-starter-react.

Zerquix18 avatar Zerquix18 commented on June 9, 2024

@mikeparisstuff this solution does not work for me. I'm using RDS and it only fails when the description has a new line

from aws-mobile-appsync-events-starter-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.