Skip to content
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

Type mutation must define one or more fields. #47

Closed
Oxymoron290 opened this issue Jul 22, 2019 · 3 comments
Closed

Type mutation must define one or more fields. #47

Oxymoron290 opened this issue Jul 22, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@Oxymoron290
Copy link

When using graphql-cli to do query introspection on my endpoint I get the error GraphQL endpoint generated invalid schema: Type mutation must define one or more fields..

I am using KGraphQL v0.6.2 and I do not have mutations designed for my endpoint.

Any ideas how I can have query-only schema (no mutations) using KGraphQL?

Here is my schema definition:

class SandDriveSchema(private val storage: SandDriveDataContext) {
    val schema = schema {
        configure {
            useDefaultPrettyPrinter = true
        }

        query("well") {
            resolver { id: Int ->
                transaction {
                    storage.getWell(id).toModel()
                }
            }
        }

        query("truckload") {
            resolver { id: Int ->
                transaction {
                    storage.getTruckLoad(id).toModel()
                }
            }
        }

        query("user") {
            resolver { id: Int ->
                transaction {
                    storage.getUser(id).toModel()
                }
            }
        }

        type<Location>()
        type<SandType>()
        type<Stage>()
        type<TruckLoad>()
        type<TruckLoadEvent>()
        type<User>()
        type<UserLocation>()
        type<Well>()
    }
}
@Oxymoron290
Copy link
Author

For now I've added the following snippet to my schema. But it's smelly and I'm curious if a better solution exists.

        mutation("_"){
            resolver {
                -> true
            }
        }

@jeggy
Copy link
Member

jeggy commented Jul 23, 2019

Sorry to say that currently there is no better solution.

This seems like an easy fix, so I will see if I can easily fix this

@jeggy jeggy added the bug Something isn't working label Jul 23, 2019
jeggy added a commit that referenced this issue Oct 3, 2019
bugfix for #47 Type mutation must define one or more fields.
@jeggy
Copy link
Member

jeggy commented Oct 3, 2019

Sorry I never got around to do this.

Thanks to Allali84 for fixing this. You can get this on the 0.7.1 release

@jeggy jeggy closed this as completed Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants