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

Is there any way to use introspection in a Relay query fragment #162

Closed
drabinowitz opened this issue Aug 24, 2015 · 3 comments
Closed

Is there any way to use introspection in a Relay query fragment #162

drabinowitz opened this issue Aug 24, 2015 · 3 comments

Comments

@drabinowitz
Copy link

The use case i have in mind is a form for creating a complex record. Ideally, I'd like to be able to use introspection to pull down a schema of the record and then use that to generate some form fields. I was wondering what you thought of this use case and/or if there is a simple way to do this in Relay. I suppose I could create a "default record" and then display that in my form, but I figured I would try being clever first.

@josephsavona
Copy link
Contributor

There's no reason why this couldn't work.

@dschafer I tried transpiling an instrospection query with babel-relay-plugin, but got an error at this line in GraphQLPrinter:

options.schema.getQueryType().getFields()[rootCallName];

Probably because the __schema field doesn't exist in the application's schema. Any ideas?

@dschafer
Copy link
Contributor

Yeah, there was some discussion whether __schema and __typename should be revealed in introspection; I think @leebyron had the most context on why they are not.

It's not clear to me that issuing an introspection query to the server at runtime would always be ideal; in particular, introspection queries might be relatively inefficient (I know this is true of Facebook's schema), and they might change underneath the client (for example, developers might add or deprecate fields on the record, so the client might get a field that it isn't familiar with).

On the other hand, using an introspection query to quickly bootstrap a client-side view seems like it would be an awesome way to get off of the ground; it might be interesting to build a mutation scaffold that would use introspection to find all mutations, then build basic form views for executing those mutations.

@josephsavona
Copy link
Contributor

Thanks for asking about this, it's an interesting idea. We'll keep this in mind going forward, but we are not likely to add this soon. I'm going to close this out but feel free to reopen if you have more questions or if this is a blocker (in which case, the change would have to happen in graphql).

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

No branches or pull requests

3 participants