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

Allow new kind of type in introspection #272

Closed
alanpoulain opened this issue Apr 15, 2018 · 3 comments
Closed

Allow new kind of type in introspection #272

alanpoulain opened this issue Apr 15, 2018 · 3 comments

Comments

@alanpoulain
Copy link
Contributor

It should be possible to create a new kind of type without having the error Unknown kind of type: MyCustomType when introspecting the schema (see https://github.com/webonyx/graphql-php/blob/master/src/Type/Introspection.php#L419).
For example, we have this type in API Platform: https://github.com/api-platform/core/blob/master/src/GraphQl/Type/Definition/InputUnionType.php
And we can't introspect the schema because of the use of this new type.
We should at least be able to extend easily the related parts (not the case since it's inside an anonymous function).

@vladar
Copy link
Member

vladar commented Apr 15, 2018

Introspection only supports type kinds defined by spec. I am not sure if we should support custom extensions like this. Did you try it with existing tools like GraphiQL? Does it work?

@alanpoulain
Copy link
Contributor Author

No it's the issue, since it's throwing an exception, GraphiQL doesn't work.
The other solution would be to implement this type in graphql-php directly, even if it's not in the spec yet.
I think there's really a need for this, there's even a pending RFC here: graphql/graphql-spec#395 (see also graphql/graphql-js#207).

@vladar
Copy link
Member

vladar commented Apr 27, 2018

I do agree that input union is a useful thing and I miss them myself. But I don't agree that we should allow non-spec-compliant custom type kinds in the base library.

The way to go for this kind of change is to support the RFC you posted previously and have it included in the spec eventually.

@vladar vladar closed this as completed Apr 27, 2018
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

2 participants