tendant / graphql-clj

A Clojure library that provides GraphQL implementation.
Eclipse Public License 1.0
285 stars 22 forks source link

Extend parser and simplify parsed syntax tree #5

Closed aew closed 7 years ago

aew commented 7 years ago

Fix a few parser bugs:

Change the parsed data structure for type-fields (including required and arguments) to:

:type-fields
   {"name" {:name "String", :arguments {"surname" {:name "Boolean"}}},
    "nickname" {:name "String"},
    "barks" {:name "Boolean"},
    "barkVolume" {:name "Int"},
    "doesKnowCommand"
    {:name "Boolean", :arguments {"dogCommand" {:name "DogCommand"}}},
    "isHousetrained"
    {:name "Boolean",
     :arguments
     {"atOtherHomes"
      {:name "Boolean", :default-value [:enum-value [:name "true"]]}}},
    "isAtLocation"
    {:name "Boolean",
     :arguments {"x" {:name "Int"}, "y" {:name "Int"}}}}

Change the parsed data structure for input-type-fields to:

:input-type-fields
   {"requiredField" {:name "Boolean", :required true},
    "intField" {:name "Int"},
    "stringField" {:name "String"},
    "booleanField" {:name "Boolean"},
    "stringListField"
    {:name "stringListField",
     :kind :LIST,
     :inner-type {:type-field-type {:name "String"}}}}}

Changed the parsed data structure for variable-definitions to:

:variable-definitions
     {"a" {:name "Int", :required true},
      "b" {:name "String", :required true}}

The :inner-type structure for lists remains inconsistent, and using :name is ambiguous (perhaps :named-type is preferable if applied consistently). Also, booleans are being misinterpreted as enums.

Add rhizome for use with insta/visualize for the raw AST.

Can you squash these commits this time again, and the next PR I'll work from a clean branch?

tendant commented 7 years ago

Thanks for the great contribution.