TypeError: __init__() got an unexpected keyword argument 'type'
See original GitHub issueHi,
I am getting a TypeError on importing graphql_compiler.compile_graphql_to_cypher
.
Stacktrace
Traceback (most recent call last):
File "graphql_compiler_redis_test.py", line 6, in <module>
from graphql_compiler import compile_graphql_to_cypher
File "/env/lib/python3.6/site-packages/graphql_compiler/__init__.py", line 3, in <module>
from .compiler import ( # noqa
File "/env/lib/python3.6/site-packages/graphql_compiler/compiler/__init__.py", line 2, in <module>
from .common import ( # noqa
File "/env/lib/python3.6/site-packages/graphql_compiler/compiler/common.py", line 4, in <module>
from . import (
File "/env/lib/python3.6/site-packages/graphql_compiler/compiler/emit_cypher.py", line 3, in <module>
from .blocks import Fold, QueryRoot, Recurse, Traverse
File "/env/lib/python3.6/site-packages/graphql_compiler/compiler/blocks.py", line 7, in <module>
from .helpers import (
File "/env/lib/python3.6/site-packages/graphql_compiler/compiler/helpers.py", line 14, in <module>
from ..schema import INBOUND_EDGE_FIELD_PREFIX, OUTBOUND_EDGE_FIELD_PREFIX, is_vertex_field_name
File "/env/lib/python3.6/site-packages/graphql_compiler/schema.py", line 26, in <module>
description='Name of the filter operation to perform.',
TypeError: __init__() got an unexpected keyword argument 'type'
Steps to Reproduce
from graphql_compiler import compile_graphql_to_cypher
System details
Linux: Ubuntu 20.04.1 LTS
Python version: 3.6.12
The output of pip list
:
Package Version
---------------- -------
arrow 0.17.0
funcy 1.15
graphql-compiler 1.11.0
graphql-core 2.3.2
pip 20.3.3
promise 2.3
python-dateutil 2.8.1
pytz 2020.5
Rx 1.6.1
setuptools 51.0.0
six 1.15.0
SQLAlchemy 1.3.22
wheel 0.35.1
PS: The python virtual environment had just graphql-compiler
installed.
Things I already tried
I tried with python v3.8.5. Got the same error.
I went through this issue https://github.com/kensho-technologies/graphql-compiler/issues/861 and made sure that the package versions are correct, especially graphql-core
as mentioned in setup.py
Digging a little more, I found that error points to L26 of graphql_compiler/schema.py. Snippet of code around there is:
FilterDirective = GraphQLDirective(
name='filter',
args=OrderedDict([(
'op_name', GraphQLArgument(
type=GraphQLNonNull(GraphQLString),
description='Name of the filter operation to perform.',
)),
('value', GraphQLArgument(
type=GraphQLNonNull(GraphQLList(GraphQLNonNull(GraphQLString))),
description='List of string operands for the operator.',
))]
),
here you are attempting to create a GraphQLArgument
with type
=GraphQLNonNull(GraphQLString),
but going through the codebase of graphql-core
v2.3.2, class GraphQLArgument
constructor is this:
class GraphQLArgument(object):
__slots__ = "type", "default_value", "description", "out_name"
def __init__(
self,
type_, # type: Union[GraphQLInputObjectType, GraphQLNonNull, GraphQLList, GraphQLScalarType]
default_value=None, # type: Optional[Any]
description=None, # type: Optional[Any]
out_name=None, # type: Optional[str]
):
# type: (...) -> None
self.type = type_
self.default_value = default_value
self.description = description
self.out_name = out_name
the constructor seems to accept the keyword argument type_
instead of type
.
So I went through your repo to find over here that this change from type
to type_
has already been done.
pip install graphql-compiler
installs v1.11.0. Should I explicitly use one of v2.0.0dev versions?
Sorry if this was a lot of info but I hope that it helps in resolving this issue. Looking forward to your reply.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Hi, Thank you for the detailed reply. Will be looking forward to v2 being released.
And yes, your guess was correct. I was trying to use
graphql-compiler
along with RedisGraph. The main motivation was to avoid writing boilerplate code converting GraphQL to Cypher, something like this library, but for RedisGraph. I came acrossgraphql-compiler
when going through this issue.Btw, redisgraph-py now supports query parameters (Ref), so maybe this doc can be updated. But yeah, RedisGraph still doesn’t have complete Cypher coverage.
Also, we really appreciate the kensho guys contributing to this project and keeping it open source (and for also writing awesome blogs!). I’ll make sure to raise PRs if I find myself modifying the code for our use-case, or if I find any bugs 😃.
Also, if I understood correctly, you mentioned that this issue is resolved in the v2.0 prereleases? If so, I’d like to mark it as closed since fixing the reported problem doesn’t require any further code changes, and simply requires v2.0 to be released.