Comments (5)
Ok, thanks for sharing that... I created a test script based on that string. Could you please run it and share the output you get?
Do you see any differences between the string in the test script and the string in your app?
require "bundler/inline"
gemfile do
gem "graphql", "2.3.0"
end
str1 = "
mutation {
createRecord(data: {
dynamicFields: { string_test: \"avenue 1st
2nd line\"},
})
{ id, dynamicFields }\
}
"
puts str1.inspect
# "\n mutation {\n createRecord(data: {\n dynamicFields: { string_test: \"avenue 1st\n 2nd line\"},\n })\n { id, dynamicFields } }\n "
str2 = GraphQL::Language.escape_single_quoted_newlines(str1)
# This one is different: it has an extra backslash ("\\n" instead of "\n"), showing that the newline was escaped:
puts str2.inspect
# "\n mutation {\n createRecord(data: {\n dynamicFields: { string_test: \"avenue 1st\\n 2nd line\"},\n })\n { id, dynamicFields } }\n "
begin
GraphQL.parse(str1)
rescue GraphQL::ParseError => err
pp [err.line, err.col, err.message]
# [4, 52, "Expected string or block string, but it was malformed"]
end
pp GraphQL.parse(str2).class
# GraphQL::Language::Nodes::Document
from graphql-ruby.
Hey, sorry for the trouble and thanks for the detailed report. Based on your examples, I added some cases to the GraphQL-Ruby test suite, but they passed as expected: 1e662f4
In your application, could you share the terminal output of puts bad_query_string.inspect
? That would help me make sure I'm using the same linebreaks and backslashes as are present in your example.
from graphql-ruby.
Interesting!
Find the output here from the bad_query_string.inspect
.
"\n mutation {\n createRecord(data: {\n dynamicFields: { string_test: \"avenue 1st\n 2nd line\"},\n })\n { id, dynamicFields }\n }\n "
from graphql-ruby.
@rmosolgo I just found the problem, our application calls GraphQL.parse
function directly to analyse query names, thus now we are also escaping from there!
::GraphQL.parse(query).definitions[0].selections[0].name
Thanks a lot for help me to identify it.
from graphql-ruby.
Glad you got to the bottom of it 👍
from graphql-ruby.
Related Issues (20)
- [Question]: Implementing input validation across the entire schema HOT 2
- OperationStore index appears to fail with nil comparsion HOT 10
- `one_of` directive doesn't work in `InputObject`s with `ActionController::Parameters` HOT 4
- Query#fingerprint raises "TypeError: no implicit conversion of nil into String" HOT 2
- [PRO] Can't get custom directive from a document retrieved from the operation store HOT 3
- Query validation never finishes on queries with many directives HOT 3
- Integrate with ActiveRecord::QueryLogs (old marginalia) HOT 5
- DataDog APM not receiving data HOT 10
- Defer is not working on fragments HOT 12
- Incompatible tracers (PrometheusTrace & SentryTrace) HOT 1
- `GraphQL::Language::Nodes::Document` is not compatible with Marshal in version 2.3 HOT 1
- Guide: Mutation authorization HOT 2
- Support directives on resolvers and mutations
- `current_field` is reset in exceptions HOT 3
- Schema type system clean-up
- dataloaders not working in autoloaded mutation arguments
- Unable to use `type` as enum value HOT 1
- Incorrect Yarn doc: execute can return a Result, not only Hash HOT 2
- Max complexity not respected when using enterprise object cache HOT 2
- Can't use fields with the name object/context, reserved terms? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-ruby.