Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: cannot unpack non-iterable DirectiveDefinitionNode object #197

Open
paras-jindal opened this issue Mar 30, 2022 · 10 comments
Open
Assignees

Comments

@paras-jindal
Copy link

while using the code generator to generate operations file i am receiving this particular error

@barbieri barbieri self-assigned this Mar 30, 2022
@barbieri
Copy link
Member

hi @paras-jindal, you need to provide the full backtrace and if possible a way to reproduce it, otherwise I'm clueless.

@barbieri
Copy link
Member

also share your setup, in particular the versions, including graphql-core.

@paras-jindal
Copy link
Author

i am so sorry for the inconvinience , i should have quoted my error along with these things
okay so..
graphql-core version ==3.1.6
sgqlc version ==15.0
so i used the terminal command

user@host$ python3 -m sgqlc.introspection
--exclude-deprecated
--exclude-description
-H "Authorization: bearer ${GH_TOKEN}"
https://api.github.com/graphql
github_schema.json
user@host$ sgqlc-codegen schema github_schema.json github_schema.py

to generate the mentioned files and it worked perfectly fine, then i generated a schema.gql file and tried to create operations.py file but its throwing error

for kind, name, code in visit(gql, visitor):

TypeError: cannot unpack non-iterable DirectiveDefinitionNode object

i tried to change verison,but still not working

@barbieri
Copy link
Member

barbieri commented Apr 1, 2022

could you try to run https://github.com/profusion/sgqlc/tree/master/examples/github?

./update-schema.sh
./update-operations.sh

I just tested with Git and it works properly (it will download an updated github_schema.json/py, but other than that the script works as expected. Worth checking with recent git (instead of 15.0), there are some fixes... I just checked and they shouldn't impact, but maybe that's the case.

@paras-jindal
Copy link
Author

hey,
i am new to all these the coding stuff , can you please elaborate step by step what i need to try in the above mentioned instructions

@paras-jindal
Copy link
Author

paras-jindal commented Apr 25, 2022

plus now i am trying it again then its throwing a different error

'GraphQLToPython' object has no attribute 'enter_leave_map'
I already updated the sgqlc as well as graphql-core packages but no luck

@barbieri
Copy link
Member

Just clone this repository, then cd examples/github and execute both scripts. They should work.

If they don't, then go to the repository root folder and execute pipenv install --dev, then pipenv shell. If you don't have pipenv, take a look at https://pipenv.pypa.io/en/latest/. Once you're inside pipenv shell, go to examples/github and execute that again, this will use the local repository (instead of the system-wide version).

NOTE: if you don't want to use a GitHub Authorization token, just export NO_DOWNLOAD=1 before executing the commands.

@paras-jindal
Copy link
Author

i just followed the mentioned steps and iw as able to do o in environment which i am using without pipenv as well as in pipenv , but the format of schema.gql i got is different then the .gql file in github repository
i think the mistake is in .gql file , can you tell me how to generate it from either node backend server or from python backend server

@barbieri
Copy link
Member

which .gql you mean? In that folder we have a github_schema.json which is the result of the introspection (you can see this in the update-schema.sh script https://github.com/profusion/sgqlc/blob/master/examples/github/update-schema.sh#L10-L15). I guess you mean this one, but it's a JSON file, not .gql. You may use a GraphQL parser (as in graphql-core or the reference https://graphql.org/graphql-js/language/#parse), then you can use an introspection on that schema... but many tools do that conversion for you. This may guide you: https://www.apollographql.com/blog/backend/schema-design/three-ways-to-represent-your-graphql-schema/

Then we have sample_operations.gql, this is manually written and represent the query/mutation you'd send to the server.

@paras-jindal
Copy link
Author

thanks , let me try this and get back to you once i get my answer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants