GraphQL: Query.type field type must be Output Type but got: undefined
For me, the problem was that I defined a graphql type and input type with the same name in my graphql schema file.
I changed this:
type InternalAttribute {
name: String
}
input InternalAttribute {
name: String
}
to this:
type InternalAttribute {
name: String
}
input InternalAttributeInput {
name: String
}
inside your schema.js as you create Object Type for String as
fields: {
name: {type: String}
}
same is needed for your custom fields too therefore
fields: {Companies}
Inside your Query type definition, you wrote:
fields: Companies
It should be
fields: { Companies }
Looking at the docs, fields takes an object or a function returning an object, with that object's keys mapping to the names of all the fields in the type (all the queries in your schema in this case).
Also, for clarity, since queries and mutations are fields of their respective types, it may be better to name them in camelCase rather than PascalCase (i.e. { companies: Companies }