simonw / datasette-graphql

Datasette plugin providing an automatic GraphQL API for your SQLite databases
https://datasette-graphql-demo.datasette.io/
Apache License 2.0
100 stars 6 forks source link

Upgrade to Graphene 3.1.0 #88

Closed simonw closed 2 years ago

simonw commented 2 years ago

I think this is breaking things.

simonw commented 2 years ago
datasette_graphql/__init__.py:4: in <module>
    from graphql.error import format_error
E   ImportError: cannot import name 'format_error' from 'graphql.error' (/opt/hostedtoolcache/Python/3.7.13/x64/lib/python3.7/site-packages/graphql/error/__init__.py)
simonw commented 2 years ago

Looks like format_error was deprecated here: https://github.com/graphql-python/graphql-core/commit/09ff14f68bdce1e9cd71decc871fd38274b01971

simonw commented 2 years ago

Found a clue here: https://github.com/graphql-python/graphql-core/blob/7c0d73a24359ac10b5fc46691ba22579f4080ce4/src/graphql/error/graphql_error.py#L259

def format_error(error: GraphQLError) -> GraphQLFormattedError:
    """
    ...
    .. deprecated:: 3.2
       Please use ``error.formatted`` instead. Will be removed in v3.3.
    """
    if not isinstance(error, GraphQLError):
        raise TypeError("Expected a GraphQLError.")
    return error.formatted
simonw commented 2 years ago

It was graphql-core that caused the bug, and upgrading to Graphene 3.1.0 doen't force an upgrade of that package, so I'm pinning to at least that version as well.