Open xmnlab opened 5 years ago
regarding MetaType
, probably for now just forcing __typename
should be enough
What is the added benefit of MetaType
?
MetaType
could store data that will enrich information about the type, like SHACL does. but maybe it is not something to address inside graphql-schema-org
. and maybe if anyone want to add that ... it probably could be added in the implementation time.
so objectively, my proposal for a next step is just:
union author = Person | Organization
Dataset {
identifier: String
author: [author]
}
In an implementation side, the resolve could receive __typename
or use ids with type name inside (e.g. Dataset/1
). So the union types would work with no problem.
for union for input type I am investigating https://www.npmjs.com/package/graphql-union-input-type ... but I don't have any feedback yet.
I have some initial example doing that here: https://github.com/Quansight/jupyterlab-metadata-service/tree/type-and-id-refactoring/backend/jupyterlab_metadata_service_server/src/schemas
where I have split that into typedefs and input
I would be very happy to create a PR here with this approach :)
let me know your thoughts
Whatever you think is good with me. I haven't had enough time to work on this recently.
awesome! thanks .. I will work on that!
hey everyone, I want to discuss the next steps for this project.
schema.org is very flexible and graphql has some limitations such as:
author
field could accept:Person | [Person!] | Organization | [Organization!] | String | [String!]
union
type doesn't support mixing objects and scalar/primitive types eg:String | Person
orPerson | [Person!]
schema.org is very flexible it allow String or List for any field (https://schema.org/docs/datamodel.html)
regarding this scenario I am proposing here to define each field as a list of a union type, eg:
so the responsibility of add one or more fields would be inside the client/frontend
it could be hard inside the resolver select what type correspond to each field/object so also maybe would be good to add some discriminator on
union input types
but maybe it could addressed in a new issue. locally in my experiments I created aMetaType
and add that into each type eg:any thoughts?