Skip to content

Upgrading to graphene v3.4.3, getting: TypeError: Expected <Schema instance> to be a GraphQL schema #1591

Closed
@guthalexander

Description

@guthalexander

Note: for support questions, please use stackoverflow. This repository's issues are reserved for feature requests and bug reports.

  • What is the current behavior?

Getting this error:
TypeError: Expected to be a GraphQL schema

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via
    a github repo, https://repl.it or similar.

Brand new virtual environment, Python 3.10

Pipfile looks like this:


[packages]
graphene = "*"

[requires]
python_version = "3.10"

and Pipfile.lock:

{
    "_meta": {
        "hash": {
            "sha256": "7a8283f892c4c8f1656b470e9ad7f0b79b5d08b21afb627bcb8f1df5d5db7933"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3.10"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "graphene": {
            "hashes": [
                "sha256:2a3786948ce75fe7e078443d37f609cbe5bb36ad8d6b828740ad3b95ed1a0aaa",
                "sha256:820db6289754c181007a150db1f7fff544b94142b556d12e3ebc777a7bf36c71"
            ],
            "index": "pypi",
            "version": "==3.4.3"
        },
        "graphql-core": {
            "hashes": [
                "sha256:2f150d5096448aa4f8ab26268567bbfeef823769893b39c1a2e1409590939c8a",
                "sha256:e671b90ed653c808715645e3998b7ab67d382d55467b7e2978549111bbabf8d5"
            ],
            "markers": "python_version >= '3.6' and python_version < '4'",
            "version": "==3.2.5"
        },
        "graphql-relay": {
            "hashes": [
                "sha256:1ff1c51298356e481a0be009ccdff249832ce53f30559c1338f22a0e0d17250c",
                "sha256:c9b22bd28b170ba1fe674c74384a8ff30a76c8e26f88ac3aa1584dd3179953e5"
            ],
            "markers": "python_version >= '3.6' and python_version < '4'",
            "version": "==3.2.0"
        },
        "python-dateutil": {
            "hashes": [
                "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3",
                "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427"
            ],
            "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
            "version": "==2.9.0.post0"
        },
        "six": {
            "hashes": [
                "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274",
                "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81"
            ],
            "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
            "version": "==1.17.0"
        },
        "typing-extensions": {
            "hashes": [
                "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d",
                "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"
            ],
            "markers": "python_version >= '3.8'",
            "version": "==4.12.2"
        }
    },
    "develop": {}
}

Executed the following in pipenv shell:

>>> import graphene
>>> class Query(graphene.ObjectType):
...     name = graphene.String()
... 
>>> import graphql
>>> new_schema = graphene.Schema(query=Query)
>>> graphql.type.validate_schema(new_schema)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/tsk147/.local/share/virtualenvs/temp-zjU4Ht41/lib/python3.10/site-packages/graphql/type/validate.py", line 62, in validate_schema
    assert_schema(schema)
  File "/Users/tsk147/.local/share/virtualenvs/temp-zjU4Ht41/lib/python3.10/site-packages/graphql/type/schema.py", line 449, in assert_schema
    raise TypeError(f"Expected {inspect(schema)} to be a GraphQL schema.")
TypeError: Expected <Schema instance> to be a GraphQL schema.

  • What is the expected behavior?
    I would expect this to be a GraphQL schema type, and the validation to pass.

  • What is the motivation / use case for changing the behavior?
    We have a legacy code application that needs to migrate to graphene v3 (in order to use the disable_introspection feature: https://github.com/graphql-python/graphene/blob/master/graphene/validation/disable_introspection.py) but when I upgrade to the latest graphene version, I get the above error.

  • Please tell us about your environment:

    • Version: graphene v3.4.3
    • Platform: Python 3.10
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions