Graphql: Unknown type String

Created on 24 Jan 2019  路  7Comments  路  Source: graphql-go/graphql

query($email:String){
getUserEmail(email: $email) {
name,
lastName
}
}

return

{
"data": null,
"errors": [
{
"message": "Unknown type "String".",
"locations": [
{
"line": 1,
"column": 16
}
]
}
]
}

Most helpful comment

solved problem!

This occurs when you have 2 types with the same name.

All 7 comments

solved problem!

This occurs when you have 2 types with the same name.

I hit this problem when trying to test a query with a schema that was not initialized (and hence was nil). Derp.

when there are 2 types with the same name there is an error in type loading.

Shouldn't we get a more explicit error message here?

@frranck

yes, it should of the problem in the application setup.

When is this problem happening? Is it when you have two different structs inside a struct with the same json tag and different definitions?

Came across the same issue and it took me ages to figure it out. Here is what @jonathanmsantosmoura meant by 2 types.
I had following 2 types defined.

var IntHistogramType = graphql.NewObject(
    graphql.ObjectConfig{
        Name: "histogram",
        Fields: graphql.Fields{
            "time": &graphql.Field{
                Type: graphql.String,
            },
            "value": &graphql.Field{
                Type: graphql.Int,
            },
        },
    },
)

var FloatHistogramType = graphql.NewObject(
    graphql.ObjectConfig{
        Name: "histogram",
        Fields: graphql.Fields{
            "time": &graphql.Field{
                Type: graphql.String,
            },
            "value": &graphql.Field{
                Type: graphql.Float,
            },
        },
    },
)

As you can see I have used the name "histogram" for both types.
As soon as these are added to my schema that crazy error occurred for all the queries with variables (even those are not related to these 2 types)
@frranck FYI

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yookoala picture yookoala  路  4Comments

sogko picture sogko  路  6Comments

rustysys-dev picture rustysys-dev  路  6Comments

amedeiros picture amedeiros  路  3Comments

yhc44 picture yhc44  路  5Comments