Compare commits

...
Author SHA1 Message Date
Muhsin 58a06dc455 fix: properly escape GraphQL strings in Linear mutations 2025-10-07 17:03:35 +05:30
+3 -2
View File
@@ -2,8 +2,9 @@ module Linear::Mutations
def self.graphql_value(value) def self.graphql_value(value)
case value case value
when String when String
# Strings must be enclosed in double quotes # Strings must be enclosed in double quotes and properly escaped
"\"#{value.gsub("\n", '\\n')}\"" escaped = value.gsub('\\', '\\\\').gsub('"', '\\"').gsub("\n", '\\n').gsub("\r", '\\r').gsub("\t", '\\t')
"\"#{escaped}\""
when Array when Array
# Arrays need to be recursively converted # Arrays need to be recursively converted
"[#{value.map { |v| graphql_value(v) }.join(', ')}]" "[#{value.map { |v| graphql_value(v) }.join(', ')}]"