Currently the description field in the GraphQl schema is null
be default for custom metadata objects such as models
, commands
, etc. This should be customisable to add desctions for a metadata type.
Descriptions can be an optional field added in the metadata subgraph which will be added to the GraphQl schema. Description can be added to the following types:
- Scalars
- Objects
- Top level object description
- Object fields
- Models
- Arguments
- select_unique type
- select_many type
- Commands
- Top level command description
- Arguments
- Relationships
User should be able to add a description to a custom scalar as follows:
{
"kind": "ScalarType",
"version": "v1",
"definition": {
"name": "CustomInt",
"description": "customInt description",
"graphql": {
"typeName": "CustomInt"
}
}
}
{
"data": {
"__schema": {
"queryType": {
"name": "Query"
},
"mutationType": {
"name": "Mutation"
},
"subscriptionType": null,
"types": [
{
"kind": "SCALAR",
"name": "CustomInt",
"description": "customInt description",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
}
],
"directives": []
}
}
}
Objects can have descriptions for the type as well as for each of the fields in the objects.
{
"kind": "ObjectType",
"version": "v1",
"definition": {
"name": "author",
"description": "author description",
"fields": [
{
"name": "author_id",
"type": "CustomInt!",
"description": "author_id description"
},
{
"name": "first_name",
"type": "String!"
},
{
"name": "last_name",
"type": "String!"
}
],
"globalIdFields": [
"author_id"
],
"graphql": {
"typeName": "Author"
}
}
}
{
"data": {
"__schema": {
"types": [
{
"kind": "OBJECT",
"name": "Author",
"description": "author description",
"fields": [
{
"name": "author_id",
"description": "author_id description",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "CustomInt",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "first_name",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
}
]
}
]
}
}
}
Models have select unique as well as select many types. Users should be able to add descriptions to them. We can also add description to the arguments for select_unique types
{
"kind": "Model",
"version": "v1",
"definition": {
"name": "Authors",
"objectType": "author",
"globalIdSource": true,
"source": {"..."},
"graphql": {
"selectUniques": [
{
"queryRootField": "AuthorByID",
"description": "AuthorByID description",
"uniqueIdentifier": [
"author_id"
]
}
],
"selectMany": {
"queryRootField": "AuthorMany",
"description": "description"
},
"filterExpressionType": "Author_Where_Exp",
"orderByExpressionType": "Author_Order_By"
},
"filterableFields": ["..."],
"orderableFields": ["..."]
}
}
{
"data": {
"__schema": {
"types": [
{
"name": "AuthorByID",
"description": "AuthorByID description",
"args": [
{
"name": "author_id",
"type": {"..."},
"defaultValue": null
}
],
"type": {"..."},
"isDeprecated": false,
"deprecationReason": null
}
]
}
}
}
{
"data": {
"__schema": {
"types": [
{
"name": "AuthorMany",
"description": "AuthorMany desc",
"args": [
{
"name": "limit",
"description": null,
"..."
},
"..."
],
"type": {"..."},
"isDeprecated": false,
"deprecationReason": null
}
]
}
}
}
{
"kind": "Model",
"version": "v1",
"definition": {
"name": "ArticlesByAuthor",
"objectType": "article",
"arguments": [
{
"name": "author_id",
"type": "Int!",
"description": "ArticlesByAuthor argument description"
}
],
"source": {"..."},
"graphql": {
"selectUniques": [
{
"queryRootField": "ArticlesByAuthorByID",
"uniqueIdentifier": [
"article_id"
],
"description": "ArticlesByAuthorByID description"
}
],
"selectMany": {
"queryRootField": "ArticlesByAuthorMany",
"description": "ArticlesByAuthorMany description"
},
"orderByExpressionType": "ArticlesByAuthorOrderBy",
"filterExpressionType": "ArticlesByAuthorWhereExp",
"argumentsInputType": "ArticlesByAuthorArgs"
},
"filterableFields": ["..."],
"orderableFields": ["..."]
}
}
{
"data": {
"__schema": {
"types": [
{
"name": "ArticlesByAuthorByID",
"description": "ArticlesByAuthorByID description",
"args": [
{
"name": "article_id",
"description": null,
"..."
},
{
"name": "author_id",
"description": "ArticlesByAuthor argument description",
"type": {
"kind": "NON_NULL",
"name": null,
"..."
}
}
],
"type": {"..."},
"isDeprecated": false,
"deprecationReason": null
}
]
}
}
}
{
"data": {
"__schema": {
"types": [
{
"name": "ArticlesByAuthorMany",
"description": "ArticlesByAuthorMany description",
"args": [
{
"name": "args",
"description": null,
"..."
}
"..."
],
"type": {"..."},
"isDeprecated": false,
"deprecationReason": null
}
]
}
}
}
If the description for select uniques/many configuration of the model is not present and model description is present, then the model description will be used for the respective configuration.
{
"kind": "Model",
"version": "v1",
"definition": {
"name": "Authors",
"description": "top level model description",
"objectType": "author",
"globalIdSource": true,
"source": {"..."},
"graphql": {
"selectUniques": [
{
"queryRootField": "AuthorByID",
"description": "AuthorByID description",
"uniqueIdentifier": [
"author_id"
]
}
],
"selectMany": {
"queryRootField": "AuthorMany",
},
"filterExpressionType": "Author_Where_Exp",
"orderByExpressionType": "Author_Order_By"
},
"filterableFields": ["..."],
"orderableFields": ["..."]
}
}
{
"data": {
"__schema": {
"types": [
{
"name": "AuthorByID",
"description": "AuthorByID description",
"args": [
{
"name": "author_id",
"type": {"..."},
"defaultValue": null
}
],
"type": {"..."},
"isDeprecated": false,
"deprecationReason": null
}
]
}
}
}
{
"data": {
"__schema": {
"types": [
{
"name": "AuthorMany",
"description": "Selects multiple objects from the model. Model description: top level model description",
"args": [
{
"name": "limit",
"description": null,
"..."
},
"..."
],
"type": {"..."},
"isDeprecated": false,
"deprecationReason": null
}
]
}
}
}
{
"kind": "Command",
"version": "v1",
"definition": {
"name": "get_article_by_id",
"description": "command description",
"arguments": [
{
"name": "article_id",
"type": "Int!",
"description": "article_id description"
}
],
"outputType": "commandArticle",
"source": {"..."},
"graphql": {
"rootFieldName": "getArticleById",
"rootFieldKind": "Query"
}
}
}
{
"data": {
"__schema": {
"types": [
{
"name": "getArticleById",
"description": "get_article_by_id description",
"args": [
{
"name": "article_id",
"description": "article_id description",
"type": {"..."},
"defaultValue": null
}
],
"type": {"..."},
"isDeprecated": false,
"deprecationReason": null
}
]
}
}
}
Description can be added to the relationship name and will be shown as a comment wherever the relationship is being used in the schema
{
"kind": "Relationship",
"version": "v1",
"definition": {
"source": "author",
"name": "Articles",
"description": "description",
"target": {
"model": {
"name": "Articles",
"relationshipType": "Array"
}
},
"mapping": ["..."]
}
}
{
"data": {
"__schema": {
"types": [
{
"kind": "OBJECT",
"name": "Author",
"description": "author description",
"fields": [
{
"name": "Articles",
"description": "description",
"args": ["..."],
"type": {"..."},
"isDeprecated": false,
"deprecationReason": null
}
]
}
]
}
}
}