-
Notifications
You must be signed in to change notification settings - Fork 86
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
Fragment Operation with inline and nested fragments "Unknown fragments..." error #211
Comments
TL;DR for this issue: The @barbieri |
@aychang95 would need to dig into the code, nothing comes to my mind right now... but I'm out of time, so if you can debug and send a patch, I can review and apply (please include doctests). A quick check in class SelectionList:
def __fragment__(self, fragment):
assert isinstance(fragment, Fragment)
self.__fragments.setdefault(
fragment.__type__.__name__, []
).append(fragment)
self.__typename__() So, if it's not crashing it's likely going in this function and what would be happening is the children |
I'm experiencing the same issue. Used sgqlc codegen for custom operations, used fragments, and can see fragment in the generated file, but when running the query getting the same error "Unknown fragment". Is this resolved yet? |
I still don't have time to look into this, as I said above it looks like a propagation to the parent selection list (where the fragment is being used). But I'd suggest to avoid this pattern of fragment inside fragment, at least until the bug is fixed. But it's not a common pattern to have immediate fragment-inside-a-fragment, I'm doing GraphQL client/server since 2017 and never had to use that, most of the time some co-worker used it was not the best approach and was blocked in code reviews. That said, if you could take a look where the propagation is missing, let me know as that will save me lots of work |
First of all, I just want to thank the maintainers of sgqlc for making such a great and useful library like sgqlc. It works very well out of the box and provides creative convenience with the codegen tool!
We're relying on
sgqlc
heavily as a dependency in our new python SDK for Golden's Knowledge Graph Protocol here https://github.com/goldenrecursion/godelSo we've been running into an issue with our fragments not working correctly with the Operations generated by codegen.
Background
We have directories containing *.graphql files in
fragments/
andqueries/
. Each file contains a single query/fragment.We run codegen to create a python module for each file.
Queries import fragments and some fragments import other fragments as well.
Problem
We have a fragment that defined as:
The Operation generated from this fragment with codegen doesn't seem to work in general and/or with nested fragments:
When running a query that uses this fragment, we get the error
Digging into the generated operations, I noticed that the Operation objects don't seem to have the fragments included even though they should have been added through lines like
_frag__as__Statement_subject.__fragment__(fragment_entity_link())
Does anyone know what seems to be going on here?
The text was updated successfully, but these errors were encountered: