Comments (4)
We used (before) GraphiQL for debugging purpose and the schema was broken due to union types (not supported by GraphiQL). So, we moved to insomnia
and no problem with schema parsing.
I've got to look at some documentation/docs about __typename
field on Input
. Thanks for feedback!
from laravel-graphql.
GraphQL spec. tells that __typename
is only used for Object
, Interface
, or Union
.
Next, you're error is not really clear. typename
should be called as __typename
(into query or objects). Can you try an other plugins/softwares to try the schema introspection like insomnia
?
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
}
}
}
}
}
}
}
}
from laravel-graphql.
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 getMutable()
, UserInput
type looks like this: (this is a part of an output to your query above)
{
"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: id
and __typename
. The JS GraphQL Plugin on WebStorm reads the defined schema, and thinks: "What the heck, why do you want to set __typename
in input, this is reserved by GraphQL" and don't work properly. When I removed __typename
on input types, everything works like a charm.
Also for me looks this __typename
on input pretty weird - I think no one will ever set this field in input... When you creates objects for you predefined table, you define only stuff for the DB. And there is no __typename
. I guess even if you define something in __typename
on input - it has no effect at all, or am I wrong?
Also here is how I understand docs. "It returns the name of the object type currently being queried." In docs is mentioned, that __typename
is used on querying, and actually you can't query an input. Also: "This field is implicit and does not appear in the fields list in any defined type.". So even if you try introspect defined queried types, in my example User type (see below), there is no __typename
field listed.
{
"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 __typename
should not be explicitly defined in input Types, so it should be removed. It would solve compatibility problem with JS GraphQL plugin on PhpStorm, and also follow docs, at least how I understood it.
from laravel-graphql.
Ok. __typename
is used to resolve morphTo
relationship. We should probably not use GraphQL reserved words to do that. I'll check that and remove it from InputObject
.
from laravel-graphql.
Related Issues (14)
- Transformers implementations
- Convert InputObjectType to Array type
- Bug with nested empty value
- Backtick sql bug when using filter transformer? HOT 2
- How to filter relations HOT 3
- Is error reporting broken? HOT 2
- N+1 Problem with ListTransformers HOT 2
- Implementing kind of auth middleware HOT 1
- Laravel 5.7 HOT 1
- Error reporting bug HOT 1
- Pipes - missing documentation + bug HOT 3
- Deleting of many2many relations HOT 1
- Truely nested relation resolvers HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-graphql.