Skip to content

[RFC]: Add namedType and punctuatedName to __Type #710

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 47 additions & 4 deletions spec/Section 4 -- Introspection.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A GraphQL server supports introspection over its schema. This schema is queried
using GraphQL itself, creating a powerful platform for tool-building.

Take an example query for a trivial app. In this case there is a User type with
three fields: id, name, and birthday.
four fields: id, name, birthday, and messages.

For example, given a server with the following type definition:

Expand All @@ -13,6 +13,7 @@ type User {
id: String
name: String
birthday: Date
messages: [Message!]!
}
```

Expand All @@ -26,6 +27,10 @@ The query
name
type {
name
punctuatedName
namedType {
name
}
}
}
}
Expand All @@ -41,16 +46,36 @@ would return
"fields": [
{
"name": "id",
"type": { "name": "String" }
"type": {
"name": "String",
"punctuatedName": "String",
"namedType": { "name": "String" }
}
},
{
"name": "name",
"type": { "name": "String" }
"type": {
"name": "String",
"punctuatedName": "String",
"namedType": { "name": "String" }
}
},
{
"name": "birthday",
"type": { "name": "Date" }
"type": {
"name": "Date",
"punctuatedName": "Date",
"namedType": { "name": "Date" }
}
},
{
"name": "messages",
"type": {
"name": null,
"punctuatedName": "[Message!]!",
"namedType": { "name": "Message" }
}
}
]
}
}
Expand Down Expand Up @@ -128,6 +153,8 @@ type __Schema {
type __Type {
kind: __TypeKind!
name: String
punctuatedName: String!
namedType: __Type!
description: String

# should be non-null for OBJECT and INTERFACE only, must be null for the others
Expand Down Expand Up @@ -242,6 +269,8 @@ Fields
* `kind` must return `__TypeKind.SCALAR`.
* `name` must return a String.
* `description` may return a String or {null}.
* `punctuatedName` must return the same value as the `name` field would.
* `namedType` must return this type.
* All other fields must return {null}.


Expand All @@ -259,6 +288,8 @@ Fields
* Accepts the argument `includeDeprecated` which defaults to {false}. If
{true}, deprecated fields are also returned.
* `interfaces`: The set of interfaces that an object implements.
* `punctuatedName` must return `name`.
* `namedType` must return a reference to the __Type object {this}.
* All other fields must return {null}.


Expand All @@ -275,6 +306,8 @@ Fields
* `description` may return a String or {null}.
* `possibleTypes` returns the list of types that can be represented within this
union. They must be object types.
* `punctuatedName` must return `name`.
* `namedType` must return a reference to the __Type object {this}.
* All other fields must return {null}.


Expand All @@ -296,6 +329,8 @@ Fields
* `interfaces`: The set of interfaces that this interface implements.
* `possibleTypes` returns the list of types that implement this interface.
They must be object types.
* `punctuatedName` must return `name`.
* `namedType` must return a reference to the __Type object {this}.
* All other fields must return {null}.


Expand All @@ -312,6 +347,8 @@ Fields
must have unique names.
* Accepts the argument `includeDeprecated` which defaults to {false}. If
{true}, deprecated enum values are also returned.
* `punctuatedName` must return `name`.
* `namedType` must return a reference to the __Type object {this}.
* All other fields must return {null}.


Expand All @@ -335,6 +372,8 @@ Fields
* `name` must return a String.
* `description` may return a String or {null}.
* `inputFields`: a list of `InputValue`.
* `punctuatedName` must return `name`.
* `namedType` must return a reference to the __Type object {this}.
* All other fields must return {null}.


Expand All @@ -348,6 +387,8 @@ Fields

* `kind` must return `__TypeKind.LIST`.
* `ofType`: Any type.
* `punctuatedName` must return `'[' + ofType.punctuatedName + ']'`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IvanGoncharov Using + for string concatenation in the spec is likely not allowed since it's a cross-language specification. Do we have any examples in the spec where concatenation is used that we could apply here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing goes for ofType.punctuatedName for referencing a field of a value. I think we might have to settle for writing this in prose, awkward though this may be:

Suggested change
* `punctuatedName` must return `'[' + ofType.punctuatedName + ']'`.
* `punctuatedName` must return the result of concatenating the `[` character, the wrapped type's `punctuatedName` value, and a `]` character.

* `namedType` must return `ofType.namedType`.
* All other fields must return {null}.


Expand All @@ -361,6 +402,8 @@ required inputs for arguments and input object fields.

* `kind` must return `__TypeKind.NON_NULL`.
* `ofType`: Any type except Non-null.
* `punctuatedName` must return `ofType.punctuatedName + '!'`.
* `namedType` must return `ofType.namedType`.
* All other fields must return {null}.


Expand Down