Hotchocolate: Emoji's in string output

Created on 10 Sep 2020  ·  13Comments  ·  Source: ChilliCream/hotchocolate

Describe the bug
@anthony-keller and @maraisr noticed emojis come out as jibberish.

To Reproduce
Return an emoji from a string field.

Expected behavior
Comes out correctly.

Desktop (please complete the following information):

  • OS: Win 10 latest
  • Version: v10.5.2
bug 🌶 hot chocolate

Most helpful comment

This one is solved with version 11.

All 13 comments

If you guys have got any more to add, feel free to add Anth/Marais. Just getting this logged.

I know Anth had an example he can probably add in.

E.g.

"Honest, friendly, customer-focused. Willing to go that little bit further to provide a positive experience������"

should be

Honest, friendly, customer-focused. Willing to go that little bit further to provide a positive experience👍

I suspect this bug with how we serialize the string with System.Text.Json looks like a simple encoding issue :) always these encoding things :D

🤑 emojis are working for me .. used the banana cake pop client

@benmccallum when does this problem occur? Are the strings broken when you write them to the server (input) or when you query them (output).

Also if they are broken on input are you sending them in through variables or as GraphQL literals in the query?

I honestly haven't looked at this one. @anthony-keller and @maraisr can chime in. I know it's when querying, but I'm not sure how it's stored in our db, rendered (playground or into html) etc.

The string is stored in SQL in a column with these properties:
image

It renders like this in SSMS
image

We query using EF and project it to a DTO using AutoMapper.

We have a REST endpoint available as well that can return reviews. It returns the following response.

"customerRatings": [ { "ratingID": 12796, "comments": "Honest, friendly, customer-focused. Willing to go that little bit further to provide a positive experience👍", } ],

If I execute this query:

query { supplier (id:194) { __typename ...on Supplier { rating { reviews { edges { node { comment } } } } } } }
I get this response
{ "data": { "supplier": { "__typename": "Supplier", "rating": { "reviews": { "edges": [ { "node": { "comment": "Honest, friendly, customer-focused. Willing to go that little bit further to provide a positive experience������" } }, { "node": { "comment": "During this normal servicing, they have genuinely identified the problem associated with my car. I have to go there after 5k, to replace front brakes shoe." } }, { "node": { "comment": null } }, { "node": { "comment": null } }, { "node": { "comment": "Front break shoes replacement was done perfectly and cost effectively. I loved the service provided, and would like to visit again for my scheduled servicing." } }, { "node": { "comment": null } }, { "node": { "comment": "I didn’t had to tell them what to do, They knew what was to be done. Perfect servicing experience , I am fully satisfied." } }, { "node": { "comment": null } }, { "node": { "comment": null } }, { "node": { "comment": null } } ] } } } } }

var comment = Ratings.Where (r => r.RatingID == 12796).Select(r => r.Comments).Single();

comment.Dump();

var asciiBytes = Encoding.ASCII.GetBytes(comment);

var asciiString = Encoding.ASCII.GetString(asciiBytes);

asciiString.Dump();

Honest, friendly, customer-focused. Willing to go that little bit further to provide a positive experience👍
Honest, friendly, customer-focused. Willing to go that little bit further to provide a positive experience??

Running a query directly against the stitched service

query {
  ratingForSupplierDbId(supplierDbId: 194, isEligibleForHighlyRecommended:false) {
    reviews {
      nodes {
        comment
      }
    }
  }
}

Gets a valid response

{
  "data": {
    "ratingForSupplierDbId": {
      "reviews": {
        "nodes": [
          {
            "comment": "Honest, friendly, customer-focused. Willing to go that little bit further to provide a positive experience👍"
          },
          {
            "comment": "During this normal servicing, they have genuinely identified the problem associated with my car. I have to go there after 5k, to replace front brakes shoe."
          },
          {
            "comment": null
          },
          {
            "comment": null
          },
          {
            "comment": "Front break shoes replacement was done perfectly and cost effectively. I loved the service provided, and would like to visit again for my scheduled servicing."
          },
          {
            "comment": null
          },
          {
            "comment": "I didn’t had to tell them what to do, They knew what was to be done. Perfect servicing experience , I am fully satisfied."
          },
          {
            "comment": null
          },
          {
            "comment": null
          },
          {
            "comment": null
          }
        ]
      }
    }
  }
}

It would appear to be caused by something in the stitching process. Hope this helps track it down.

Yes it helps. I tried it with a local GraphQL server and could not get the issue. Will have a look at the stitching layer.

This one is solved with version 11.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benmccallum picture benmccallum  ·  3Comments

marcin-janiak picture marcin-janiak  ·  4Comments

lTimeless picture lTimeless  ·  5Comments

sfmskywalker picture sfmskywalker  ·  3Comments

nigel-sampson picture nigel-sampson  ·  5Comments