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

Support for defining metadata on graphql types #200

Closed
aschrijver opened this issue Jul 30, 2016 · 8 comments
Closed

Support for defining metadata on graphql types #200

aschrijver opened this issue Jul 30, 2016 · 8 comments

Comments

@aschrijver
Copy link

It would be nice if the specification defined a standard way to define metadata in a schema definition for individual types, interfaces, fields, etc. This would not be query metadata, like you have with directives, but e.g. server implementation specific metadata, or whatever an implementer needs to model additional logic on top of a schema. In other words a general metadata extension mechanism.

I described this in more detail and with examples on the graphql-java project in this issue: graphql-java/graphql-java#183

Maybe the metadata mechanism could be implemented using an additional introspection type __METADATA or something similar.

WDYT?

@OlegIlyenko
Copy link
Contributor

I think it's a interesting idea. Especially now that schema definition language (IDL) supports directives as well. This information is not exposed to a client via introspection API and, at the moment, only part of the AST.

In sangria (scala implementation), for instance, there is a concept of FieldTags which allows user to attach additional meta-information to a an ObjectType fields. This meta-information can be used in middleware or query reducers to provide more application-specific information about the fields. But this meta-information is not exposed to a client in any way either.

I find that it can beneficial to expose this application-specific meta-information to a client via introspection API. Maybe it can be exposed in a form of directives? For example a __Type can have a filed called directives and it will expose a list of directives (these are not directive definitions, like in top-level field, but rather an actual directive application).

I think it would be helpful if you could list a few use-cases that demonstrate how client can benefit from using this meta-information exposed via introspection API.

@aschrijver
Copy link
Author

Yes I can. First of all I think it is important to see that the 'client' is much more than client-side javascript that executes queries against a HTTP GraphQL endpoint (as you usually encounter it). It has been stated that GraphQL is ideal in a microservices environment. And it is. In these kind of applications queries may cross many boundaries and use many different transports. So you can have multiple clients (and publishers) in one execution chain. Metadata can be used here for infrastructure support and configuration settings, for example.

In my own use case for vertx-graphql-schema-proxy and vertx-graphql-service-discovery I want to use it for marshalling settings and to determine the point from which a query is no longer allowed to execute on the proxy client, but should be deferred to the backend.

@aschrijver
Copy link
Author

aschrijver commented Jul 31, 2016

Its not only these more environment-specific metadata that could be relevant, but you could also use it to add much more descriptive information on the type definition itself. Think of a category, list of keywords, access modifiers, RDF descriptors, documentation links, related types, localization data, etc.

@aschrijver
Copy link
Author

Oh. Almost forgot to mention. The __METADATA can be used to define expected metadata formats just like you have for types.

@aschrijver
Copy link
Author

aschrijver commented Jul 31, 2016

See also the discussion on GraphQL Java project for adding metadata. I added additional use cases: graphql-java/graphql-java#183 and my comment here #163 (comment)
The issue has been closed because there is nothing similar in graphql-js and graphql-java is following that as a reference implementation.

@leebyron I would be quite interested in your views on this topic.

@taion
Copy link

taion commented Dec 20, 2017

I believe this is essentially a dupe of #300, which has more discussion, and as such should be closed out.

@aschrijver
Copy link
Author

thanks @taion
closing in favour of #300

@wtrocki
Copy link

wtrocki commented Jun 3, 2020

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

4 participants