-
Notifications
You must be signed in to change notification settings - Fork 21
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
How to design a type-safe JSON endpoint where output fields depend on incoming request? #10
Comments
This immediately brings up horror stories...
I believe if you need flexibility in selecting the fields then we can use GraphQL (http://graphql.org/) http://graphql.org/blog/rest-api-graphql-wrapper/ http://stackoverflow.com/questions/38339442/json-schema-to-graphql-schema-converters Let me know your thoughts |
Wrt GraphQL, yes, this is an ad-hoc way of implementing the same ideas that GraphQL is trying to solve. However, I haven't researched GraphQL deeply. Can you help me with the following questions:
|
I mentioned GraphQL as it might be useful for your use cases.
Having said all that, I am not going to jump into GraphQL right away. I am still evaluating as I want to avoid using JavaScript... if I have time, then I might try to build a library in PureScript (node.js). Even though I can use GraphQL rightaway too... then I will need to use Haskell for REST API Endpoints and GraphQL server (node.js) and use that in PureScript client with FFI. Right now Haskell API end points and then in the future GraphQL / Apollo (http://www.apollostack.com/) |
if you really want to implement this, then I can think of a way.
doable... a little messy and no guarantees! I am not sure if I will want to do something like this |
I think if you want to just send certain fields of a record, you would want to box every field value of the record with something like a To specify, in the query request, which fields you want to get back in the response, you'd send a whole record (i.e. a product record) with every field having a |
Hey @mpdiary, thanks for chiming-in. If the whole product record gets sent with missing fields as
So, a custom This problem is similar to how most DB libraries need to deal with missing columns in SQL queries. |
Oh, you're right, that would be a lot of overhead. Well it looks like you can use the alternative
Then you can do:
And the omitted fields are just given a |
Note: This may be closely related to #9
Examples:
The text was updated successfully, but these errors were encountered: