walmartlabs / lacinia

GraphQL implementation in pure Clojure
http://lacinia.readthedocs.io/en/latest/
Other
1.82k stars 160 forks source link

Unbalanced braces in queries not causing parse-query to fail #445

Open neilprosser opened 1 year ago

neilprosser commented 1 year ago

This is tested with 1.2.1.

We use Lacinia to quickly validate GraphQL queries we define in code to try and avoid committing something invalid. I noticed a couple of examples of typos which don't cause com.walmartlabs.lacinia.parser.query/parse-query to fail:

(ns temp
  (:require [com.walmartlabs.lacinia.parser.query :as pq]))

;; Brace switched with paren end of line 1 - Throws an exception
(pq/parse-query "query (
  myQuery {
    name
  }
}")

;; Missing brace end of line 1 - Doesn't throw an exception
(pq/parse-query "query
  myQuery {
    name
  }
}")

;; Missing brace end of line 2 - Doesn't throw an exception
(pq/parse-query "query {
  myQuery
    name
  }
}")

These queries are then failing when they are sent to a service using Lacinia for its GraphQL handling.