tendant / graphql-clj

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

Unknown argument ... on field ... of type ... #50

Closed ku1ik closed 7 years ago

ku1ik commented 7 years ago

Given the following schema:

    (def schema-str "schema {
      query: Query
    }

    type Query {
      a: A
      x: X
    }

    type A {
      b: B
    }

    type B {
      c(foo: Int): String
    }

    type X {
      y(foo: Int): String
    }
    ")
(def type-schema (-> schema-str parser/parse validator/validate-schema))

I'm getting validation error for this query:

(-> "{ a { b { c(foo: 1) } } }" parser/parse (validator/validate-statement type-schema))
; => {:errors [{:error "Unknown argument 'foo' on field 'c' of type 'String'.", :loc {:line 1, :column 13}}]}

While this one works:

(-> "{ x { y(foo: 1) } }" parser/parse (validator/validate-statement type-schema))
; => {:document {:operation-definitions [{:section :operation-definitions, :node-type :operation-definition, :operation-type {:type "query"}, :selection-set [{:selection-set [{:field-name "y", :node-type :field, :args-fn #function[clojure.core/constantly/fn--4614], :kind :SCALAR, :parent-type-name "X"}], :field-name "x", :node-type :field, :kind :OBJECT, :parent-type-name "Query"}]}], :type-system-definitions nil, :fragment-definitions nil}}

This is on 0.1.20.

tendant commented 7 years ago

Sorry for the late response. This issue is caused by validation graphql-clj.validator.rules.known-argument-names.

I am refactoring all validation processes at this moment. This issue will be included once it is done.

tendant commented 7 years ago

This issue is fixed in 0.2.0-alpha. Version 0.2.0 will be released soon.

You can find the new code in branch https://github.com/tendant/graphql-clj/tree/new-ast

ku1ik commented 7 years ago

Thanks!

tendant commented 7 years ago

The new version 0.2.0 has been release. Code has been pushed in master. A lot of things have been rewritten in the new version.

This issue is fixed.