Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending double quotes and backslash in Graphql request

I want to send double quote(") and back slash(\ ) in Graphql request and want to get it back in response.

Please check bellow example:

mutation M { 
    signUp
    (
        name: "Harsha Vardhan"
        username: "Harsha143", 
        email: "[email protected]",
        description: "Cool "boy" \n And good looking."
    ) 
    {
        _id,
        name
        username,
        email,
        description
}

In above Mutation I want to send double quotes and back slash in description. Please guide me to overcome this.

Thanks in advance.

like image 964
Harsha Vardhan Avatar asked Jun 08 '16 17:06

Harsha Vardhan


People also ask

Is GraphQL query case sensitive?

Names in GraphQL are case‐sensitive. That is to say name , Name , and NAME all refer to different names.

What are the three types of operations in GraphQL?

GraphQL works by sending operations to an endpoint. There are three types of operations: queries, mutations, and subscriptions.

What is Operation name in GraphQL?

The operation name is pretty much up to you on what you want to call it. However, you do need it when you pass in query / mutation parameters like so: // GraphQL Query query Welcome ($data: String!) { echo (email: $data) { name } } // GraphQL Variables { "data": "[email protected]" }

What is the name of GraphQL include reusable units in queries and mutations?

A GraphQL fragment lets you build multiple fields, and include them in multiple queries. You can think of it as functions in programming languages, that are reusable units. A GraphQL Fragment is a reusable unit of a GraphQL query, which creates a shared piece of query logic.


1 Answers

You should try to escape those characters like so

mutation M { 
    signUp
    (
        name: "Harsha Vardhan"
        username: "Harsha143", 
        email: "[email protected]",
        description: "Cool \"boy\" \\n And good looking."
    ) 
    {
        _id,
        name
        username,
        email,
        description
}

Hope that helps!

like image 130
vince Avatar answered Oct 19 '22 15:10

vince