Skip to content

Using mutation String argument with multiline text #1169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
realsuayip opened this issue Mar 29, 2020 · 1 comment
Closed

Using mutation String argument with multiline text #1169

realsuayip opened this issue Mar 29, 2020 · 1 comment

Comments

@realsuayip
Copy link

What's the proper way to send a multiline text to a mutation argument? Sending a text with newline characters causes Syntax Error GraphQL (xxx) Unterminated string. Using this reference, I tried block strings, but it didn't really work.

Set up:

class WishTopic(Mutation):
    class Arguments:
        title = String()
        hint = String()

    feedback = String()
    ...

Query:

mutation {
  topic {
    wish(title: "foo", hint: """bar""") {
      feedback
    }
  }
}

Result:
Syntax Error GraphQL (xxx) Expected Name, found String

Am I missing something?

@jkimbo
Copy link
Member

jkimbo commented Apr 1, 2020

@realsuayip you probably want to pass the string as an argument to your mutation like this:

mutation = """
mutation TestMutation($hint: String) {
  wish(title: "foo", hint: $hint) {
    feedback
  }
}
"""

results = schema.execute(
	mutation,
	variable_values={
		"hint": """
bar
""",
	}
)

@jkimbo jkimbo closed this as completed Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants