Skip to content

Instantly share code, notes, and snippets.

@BEaStia
Last active October 3, 2017 08:20
Show Gist options
  • Save BEaStia/a58693c39f7a87771953205d1a0d4e62 to your computer and use it in GitHub Desktop.
Save BEaStia/a58693c39f7a87771953205d1a0d4e62 to your computer and use it in GitHub Desktop.
oh my god
def extract_info_from_query_or_vars(query)
input_hash = eval(extract_values_from_mutation(query))
if @variables.present?
return { device_id: @variables[:deviceId],
email: @variables[:email],
password: @variables[:password],
fb_token: @variables[:fbToken] }
end
{ device_id: input_hash[:deviceId],
email: input_hash[:email],
password: input_hash[:password],
fb_token: input_hash[:fbToken] }
end
def extract_values_from_mutation(query)
# For now this works this way, the only mutations will be for signup
# Since I had little time I parse them manually a regexp not always worked.
# Ale
input_index_considering_word = query.index('input:') + 6
aux = query[input_index_considering_word..query.length]
inputs = ''
aux.chars.each do |char|
inputs << char unless char.empty?
break if char == '}'
end
inputs
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment