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

Exportable schema #266

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

davewasmer
Copy link
Contributor

This is an initial pass at exportable schema (see #234). I fully expect that this will not cover all edge cases, but I just wanted to get something up to start the discussion / iterate from. @neumino - does this seem like a good approach? Anything you'd like to see changed?

I'd personally also like to see the ability to export relationships (I'm fine if that's independent of exporting schema), but I'll address that in a separate PR most likely.

@davewasmer
Copy link
Contributor Author

Apologies for the messy diff - I thought I skipped those hunks when adding, but I guess not.

On that thought - @neumino, would you be open to a PR that cleans up the code a bit? I.e. trims whitespace, adds missing semicolons, etc?

@neumino
Copy link
Owner

neumino commented Jun 17, 2015

Hello @davewasmer

I actually don't remember what the use case for exporting schema was. Why do you need to be able to export a schema?

Your PR currently seems to export a human readable schema, but doesn't export more properties like the maximum length, if the field is required or not etc.
So you probably need export basically the whole object in each type/<type>,js

@davewasmer
Copy link
Contributor Author

My use case is primarily around reflection. I'm trying to serialize a Thinky model into different JSON formats, without hardcoding per-model serializers. So having the ability to export the schema provides me a way to inspect the model's schema at runtime and dynamically serialize it. If there is a better approach here that I'm missing, let me know 😄

Right now, yes, the export is human-readable. Like I mentioned, this is just a proof of concept, it should be easy to modify the .export() functions to export whatever we'd like. I just wanted to get your take on the concept first.

@neumino
Copy link
Owner

neumino commented Jun 18, 2015

The basic implementation seems reasonable to me.
Instead of just exporting the type, we should export the whole Type object (with all its attributes + its type).

There's also a need to import the schema after that :)

@tlvenn
Copy link

tlvenn commented Aug 6, 2015

One more use case would be to assist building GraphQL schema.

@tlvenn
Copy link

tlvenn commented Sep 15, 2015

Any chance to see that PR merged ?

@neumino
Copy link
Owner

neumino commented Sep 15, 2015

This PR is kind of incomplete. I'll comment more on the issue.

@yocontra
Copy link

+1 - this is also super important for us

@neumino
Copy link
Owner

neumino commented Jan 13, 2016

@contra -- what is it for?

@yocontra
Copy link

@neumino Generating redux api actions on the front-end + form validation etc.

@yocontra
Copy link

How does this deal with relationships? It would be super helpful if those were also part of the export

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants