Open priyatam opened 5 years ago
Hi,
The schema should be the uncompiled schema. It looks like your schema has custom scalars, so are you supplying generators for those custom scalars to lacinia-gen?
The example on the readme shows how to use it if you have custom generators: https://github.com/oliyh/lacinia-gen#custom-scalars
Hope this helps.
Additionally is your query here correct? Your schema declares that get_countries
has a query_str parameter that you are providing as arguments but not supplying in the query, I would expect it to look like this (in it's simplest form):
(let [f (lg-query/generate-fn schema {})]
(f "query { get_countries(query_str: \"IN\") { countries } }"))
Yes, I'm passing scalars, like so, and still get an error:
(let [gen (gen/generator schema {:scalars {:Datetime (local-date-time)}})]
(g/sample (gen :LenderReferral) 1))
> Resolver specified in schema not provided.
{:reference :mutation/save-application-data,
:callbacks (:query/get-lender-options
:query/get-validation-edits
:query/get-countries
:query/get-application-details
:query/get-profile-lists
:query/get-drop-downs
:query/get-member-by-id
:query/get-profile-options)}
Hmm, that last error comes from Lacinia, not lacinia-gen. I guess you have :mutations
in your schema? I think the issue might be that lacinia-gen is not mocking mutation resolvers and Lacinia is throwing the error. (This is only with lacinia-gen.query
, lacinia-gen.core
should be ok).
I removed :mutations :input-objects :enums
from the raw schema, and yet get this error:
Assert failed: Second arg to fmap must be a generator (generator? gen)
generators.cljc: 100 clojure.test.check.generators$fmap/invokeStatic
generators.cljc: 91 clojure.test.check.generators$fmap/invoke
To take a step back, I'd be happy just relying on generating object graphs, instead of query api. What do you think is required to provide this support with a working schema.edn? I'd be happy to contribute if you can point to the code.
Hi,
Can you share a minimum failing schema and I can have a look? Is it your get_countries one in your first post?
Thanks
Sure, I'll provide this soon ...
I have a working schema that compiles successfully with lacinia. However lacinia-gen throws multiple errors for both full graph and query result apis, for simple objects and objects with nested and input objects. It's not apparent from the test-check errors what's missing.
For most objects, I get a NullpointerException.
It is also not clear whether the 'schema' passed to lacinia-gen is a raw edn schema, or a compiled schema from lacinia (see
load-schema
)I've used both variations and get NPEs with a compiled schema.
With queries, I always get the same error:
Cannot query field get_countries on type QueryRoot ... :extensions {:field get_countries, :type :QueryRoot}
The above query works fine on graphiql.
Any suggestions debugging these errors is much appreciated. I'm also using your re-graph library.