graphql-python / graphene-django

Build powerful, efficient, and flexible GraphQL APIs with seamless Django integration.
http://docs.graphene-python.org/projects/django/en/latest/
MIT License
4.31k stars 769 forks source link

SyntaxError When Trying to Run Django Project with Graphene #1448

Closed faresemad closed 1 year ago

faresemad commented 1 year ago

Hello,

I am currently working on a large Django project that utilizes the Graphene framework to implement GraphQL in the application. I've encountered an issue while attempting to run the project, where a SyntaxError is raised, pointing to the graphene_django/__init__.py file on line 1. Error message:

SyntaxError: invalid syntax
File "/media/fares/01D884D05EFC32C0/Projects When Learn/GraphQl/graphql/books/urls.py", line 3, in <module>
from graphene_django.views import GraphQLView
File "/media/fares/01D884D05EFC32C0/Projects When Learn/GraphQl/graphql/.venv/lib/python3.11/site-packages/graphene_django/__init__.py", line 1
xfrom .fields import DjangoConnectionField, DjangoListField

Upon investigating the issue, I noticed that there is a mistake in the import statement in the graphene_django/__init__.py file on the first line. An extra "x" character was mistakenly included at the beginning of the line. Screenshot from 2023-08-09 21-29-43

The correct import should be as follows:

from .fields import DjangoConnectionField, DjangoListField

Please review your imports in this file and related files to ensure proper syntax.

I hope this information proves helpful, and feel free to reach out if you need further assistance or have additional questions.

Thank you very much!

erikwrede commented 1 year ago

Hey there, this is indeed a bug. Moving to graphene-django. For a fix, please downgrade to 3.1.3. @firaskafri

sjdemartini commented 1 year ago

We should probably also change the publish workflow (https://github.com/graphql-python/graphene-django/blob/main/.github/workflows/deploy.yml) so that it runs the full CI first (tests, etc) and only publishes when successful.