TypeError: __init__() got an unexpected keyword argument 'type'
MrinalUdhoji opened this issue · 5 comments
I am using Pycharm latest version with Python 3.8. (I also tried with 3.7 but it is throwing same error). GraphQl compiler version is 1.11.0, garaphql core is 3.1.1 and graphql is 0.0.1.
The code is throwing error while importing from the package. I tried debugging it showing error at line no 10 where I am importing from the graphql-compiler package which why I suspected that I am using the wrong version.
If someone has come across the same error please do let me know.
P.S. I am still a learner and just started dealing with graphql and orientdb.
`import pyorient
from owlready2 import *
import rdflib
from rdflib.graph import Graph, Store, URIRef, Literal
from rdflib.namespace import Namespace, RDFS
from rdflib import plugin
import requests
from pyorient import *
from pyorient import OrientSocket
from graphql_compiler import graphql_to_match
from graphql_compiler import get_graphql_schema_from_orientdb_schema_data
from graphql_compiler.schema_generation.orientdb.utils import ORIENTDB_SCHEMA_RECORDS_QUERY
from graphql.utilities.print_schema import print_schema
from graphql_compiler import *
from pyorient.ogm import Config, Graph
client = pyorient.OrientDB("127.0.0.1", 2424)
session_id = client.connect("root", "1234")
client.db_open("Orient", "root", "1234", pyorient.DB_TYPE_GRAPH)
schema_records = client.command(ORIENTDB_SCHEMA_RECORDS_QUERY)
schema_data = [record.oRecordData for record in schema_records]
schema, type_equivalence_hints = get_graphql_schema_from_orientdb_schema_data(schema_data)
print(print_schema(schema))
graphql_query = '''
{
DetectionUnit {
}
}
'''
compilation_result = graphql_to_match(schema, graphql_query, type_equivalence_hints)
print([result.oRecordData for result in client.query(graphql_query)])`
Hi! Thanks for checking out our package!
It seems like your environment's installed packages have somehow gone out of sync with the GraphQL compiler's dependencies. For GraphQL compiler v1.11.0, you can see here that its requirement is graphql-core>=2.1,<3
and yet you said you have graphql-core==3.1.1
installed. This is very likely the reason the exception is raised.
I'm not sure how your versions might have gotten out of sync. To resolve the situation, I'd suggest uninstalling graphql
and graphql-core
, and then reinstalling the graphql-compiler
package with pip which should make sure appropriate versions of those dependencies are installed.
I looked into this some more, and I think the reason is that you have a conflict between graphql
and graphql-core
. The graphql
library is not a dependency of graphql-compiler
nor of graphql-core
, so it must either be a direct requirement of your project, or of some other library you are installing. This is causing a problem because both graphql
and graphql-core
are attempting to install a Python module called graphql
(i.e. import graphql
in Python could resolve to either of them, or to a corrupted mashup of both, I believe the expected outcome is undefined), and likely overwriting each other's files or causing some other kind of conflict.
Since graphql-core
and graphql
are mutually incompatible, and graphql-core
is a dependency of GraphQL compiler, that means you'll need to remove the graphql
module from the list of packages you are installing, and then reinstall everything except graphql
to repair your environment. graphql-core
is a full GraphQL library that should be able to do anything you may have been using graphql
for, so I'd suggest switching to it to avoid this problem.
Hope this helps!
Thank you for your response. I tried everything as you suggested but unfortunately, I am still getting the same error.
May I suggest wiping your installation environment, and then installing the dependency packages from scratch, making sure that you do not pull in the graphql
package from anywhere?
Beyond this, I'm only able to suggest looking for inspiration at some of our example projects that are already fully set up, and comparing their setup to your own:
https://github.com/kensho-technologies/game-of-graphql
https://github.com/obi1kenobi/graphql-compiler-cross-db-example