-
Notifications
You must be signed in to change notification settings - Fork 5
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
__typename field on Input types #31
Comments
We used (before) GraphiQL for debugging purpose and the schema was broken due to union types (not supported by GraphiQL). So, we moved to I've got to look at some documentation/docs about |
GraphQL spec. tells that Next, you're error is not really clear. sudo snap install insomnia and try the following GraphQL query ? query IntrospectionQuery {
__schema {
queryType { name }
mutationType { name }
subscriptionType { name }
types {
...FullType
}
directives {
name
description
locations
args {
...InputValue
}
}
}
}
fragment FullType on __Type {
kind
name
description
fields(includeDeprecated: true) {
name
description
args {
...InputValue
}
type {
...TypeRef
}
isDeprecated
deprecationReason
}
inputFields {
...InputValue
}
interfaces {
...TypeRef
}
enumValues(includeDeprecated: true) {
name
description
isDeprecated
deprecationReason
}
possibleTypes {
...TypeRef
}
}
fragment InputValue on __InputValue {
name
description
type { ...TypeRef }
defaultValue
}
fragment TypeRef on __Type {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
}
}
}
}
}
}
}
} |
Sorry, I didn't notice, that markdown parsed __ away, I edited the error, displayed by plugin. I guess you misunderstood me =) So I'll try to describe what is going on. When I create a Definition, then this lib generates much types, among other things also Input types. E.g. I have a definition for a user table. With an empty array in {
"kind": "INPUT_OBJECT",
"name": "UserInput",
"description": null,
"fields": null,
"inputFields": [
{
"name": "id",
"description": null,
"type": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
},
"defaultValue": null
},
{
"name": "__typename",
"description": null,
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
}
],
"interfaces": null,
"enumValues": null,
"possibleTypes": null
} So clearly for user mutation (user or users - so for creation of users), I can set following fields in input: Also for me looks this Also here is how I understand docs. "It returns the name of the object type currently being queried." In docs is mentioned, that {
"data": {
"__type": {
"kind": "OBJECT",
"name": "User",
"description": "Represents a User",
"fields": [
{
"name": "id",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "email",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "created_at",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "Datetime",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "updated_at",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "Datetime",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
}
}
} Summarised: I think, that |
Ok. |
Hi, I just installed a plugin on my PhpStorm: JS GraphQL. It has a great support for working with graphql. When I parsed my schema with this plugin, it threw me an error:
Error: Name "__typename" must not begin with "__", which is reserved by GraphQL introspection.
So my question - Is there any sense in appending
__typename
field of type "string" to all input types for definitions? I didn't see this in other gql schemas before.Can we get rid of it? I also didn't find any example for creation Input types with
__typename
field.The text was updated successfully, but these errors were encountered: