Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate automatic input and output schema detection in attach-query and attach-mutation #4

Open
acron0 opened this issue Jan 11, 2019 · 7 comments
Labels
enhancement New feature or request help wanted Extra attention is needed low priority

Comments

@acron0
Copy link
Member

acron0 commented Jan 11, 2019

It's theoretically possible to discern the schemas from the fdef (if one exists) rather than have the user supply schema.

For example, instead of (attach-query ::input ::output handler) you could just do (attach-query handler) and the function would find an fdef associated with handler, detect the :args and :ret (thanks @devurandom) and use these in place of input and output specs.

This is just sugar, really, but might help with onboarding

@acron0 acron0 added enhancement New feature or request help wanted Extra attention is needed labels Jan 11, 2019
@devurandom
Copy link

There is s/get-spec to retrieve the spec of a fully qualified symbol. It should contain :args and :ret keys.

@acron0 acron0 added good first issue Good for newcomers and removed good first issue Good for newcomers labels May 1, 2019
@workshub
Copy link

workshub bot commented Sep 25, 2019

@tolgraven started working on this issue via WorksHub.

tolgraven added a commit to tolgraven/leona that referenced this issue Sep 25, 2019
and WorksHub#11 (description support), both working but in need of tests
eetc and especially design decisions before any further work.
@workshub
Copy link

workshub bot commented Dec 11, 2019

A user started working on this issue via WorksHub.

1 similar comment
@workshub
Copy link

workshub bot commented Dec 19, 2019

A user started working on this issue via WorksHub.

@workshub
Copy link

workshub bot commented Mar 27, 2020

If you successfully complete this Issue via WorskHub there's a $25 reward available.
Start work via WorksHub Issue Details page.

@benjamin-asdf
Copy link
Contributor

benjamin-asdf commented Jan 25, 2023

Challenge

Investigated this and there is a challenge:
When you s/def, you provide a sequence-spec for the arglist. So it is not
simplistic to "get" the query spec (the second arg). The spec might be
a function at this point.

If users would always fdef using s/cat we might able to
extract the spec but now we are making more assumptions than we
should imo.

Another constraint we impose on the user is that their sepcs must be
keywords, not functions. Unless ::query-spec can be allowed to be function.

#40 Makes an erronous assumption in my analysis. The :args spec
would be for a list [ctx query value], but we would want to extract
the spec for query or the 2nd arg specifically.

So in my opinion we would not be able to provide this sugar in a way
that still is simple. We are better of taking the spec as param.

I asked on slack and Alex Miller said there is currently not really a
good way to get an arg spec like that. https://clojurians.slack.com/archives/C1B1BB2Q3/p1674644797222099

Alternative:

There would be an alternative maybe in conjunction with #11 to check
metadata on the resolver-fn.

We could then have something like:

(defn
  ^{:leona/query-spec ::test/driod-query
    :leona/results-spec ::test/droid}
  droid-resolver
  [ctx query value])

This would be trivial to implement and I suppose nice for users that
have a resolver function using the same specs in a lot of places.

@acron0
Copy link
Member Author

acron0 commented Feb 1, 2023

I do like the metadata approach. I wish this had been used more in the original design of Leona as well.

benjamin-asdf added a commit to benjamin-asdf/leona that referenced this issue Feb 4, 2023
acron0 added a commit that referenced this issue Feb 8, 2023
Add query and mutation specs from resolver-fn metadata #4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed low priority
Projects
None yet
Development

No branches or pull requests

3 participants