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

GraphQLError unknown type #531

Closed
jimshepherd opened this issue Aug 22, 2017 · 2 comments
Closed

GraphQLError unknown type #531

jimshepherd opened this issue Aug 22, 2017 · 2 comments

Comments

@jimshepherd
Copy link

Trying to get a pyramid / sqlalchemy / graphene server to work with a Relay example:
relay modern todo example
but am receiving an error when running a mutation (queries work fine):

GraphQLError('Unknown type "RenameTodoInput".',)

relevant schema:

class Todo(SQLAlchemyObjectType):
    class Meta:
        model = TodoModel
        interfaces = (relay.Node, )


class RenameTodo(relay.ClientIDMutation):
    class Input:
        text = graphene.String(description='Text', required=True)
        id = graphene.Int(description='Todo Id', required=True)

    todo = graphene.Field(Todo)
    ok = graphene.Boolean()

    @staticmethod
    def mutate_and_get_payload(root, args, context, info):
        todo_id = args.get('id')
        todoModel = Todo.get_query(context).first()
        todoModel.text = args.get('text')
        todo = Todo(todoModel)
        ok = True
        return RenameTodo(todo=todo, ok=ok)


class Mutations(graphene.ObjectType):
    renameTodo = RenameTodo.Field()

the Relay mutation:

const mutation = graphql`
  mutation RenameTodoMutation($input: RenameTodoInput!) {
    renameTodo(input:$input) {
      todo {
        id
        text
      }
    }
  }
`;

the actual request:
{"query":"mutation RenameTodoMutation(\n $input: RenameTodoInput!\n) {\n renameTodo(input: $input) {\n todo {\n id\n text\n }\n }\n}\n","variables":{"input":{"text":"Do something","id":"QmVlcjox"}}}

schema.introspect() seems to indicate that the type is being created:

            "types": [
                ...
                {
                    "kind": "INPUT_OBJECT",
                    "name": "RenameTodoInput",
                    "description": null,
                    "fields": null,
                    "inputFields": [
                ...

I have tried creating a custom RenameTodoInput class, but still received the same error.

Versions:
graphene (1.4.1)
graphene-sqlalchemy (1.1.1)
graphql-core (1.1)
graphql-relay (0.4.5)

Any help is appreciated.

@totaki
Copy link

totaki commented Aug 23, 2017

    class Input:
        text = graphene.String(description='Text', required=True)
        id = graphene.Int(description='Todo Id', required=True)

This schema say you can use only:

  mutation RenameTodoMutation($textValue: String!, $idValue: Int!) {
    renameTodo(text: $textValue, id: $idValue) {
      todo {
        id
        text
      }
    }
  }

For custom types you need use http://docs.graphene-python.org/en/latest/types/scalars/

@jkimbo
Copy link
Member

jkimbo commented Feb 17, 2018

Hi @jimshepherd . We're currently going through old issues that appear to have gone stale (ie. not updated in about the last 6 months) to try and clean up the issue tracker. If this is still important to you please comment and we'll re-open this.

Thanks!

@jkimbo jkimbo closed this as completed Feb 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants