Skip to content

Exportable schema#266

Open
davewasmer wants to merge 1 commit into
neumino:masterfrom
davewasmer:schema-export
Open

Exportable schema#266
davewasmer wants to merge 1 commit into
neumino:masterfrom
davewasmer:schema-export

Conversation

@davewasmer

Copy link
Copy Markdown
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
Copy Markdown
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

neumino commented Jun 17, 2015

Copy link
Copy Markdown
Owner

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
Copy Markdown
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

neumino commented Jun 18, 2015

Copy link
Copy Markdown
Owner

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

tlvenn commented Aug 6, 2015

Copy link
Copy Markdown

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

@tlvenn

tlvenn commented Sep 15, 2015

Copy link
Copy Markdown

Any chance to see that PR merged ?

@neumino

neumino commented Sep 15, 2015

Copy link
Copy Markdown
Owner

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

@yocontra

Copy link
Copy Markdown

+1 - this is also super important for us

@neumino

neumino commented Jan 13, 2016

Copy link
Copy Markdown
Owner

@contra -- what is it for?

@yocontra

Copy link
Copy Markdown

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

@yocontra

Copy link
Copy Markdown

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