-
Notifications
You must be signed in to change notification settings - Fork 229
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
Documentation on connection_field_factory #228
Comments
The problem here is that |
Same exact issue. Whats odd to me is that it happens when you add more than one class that uses SQLAlchemyObjectType. With only one class subclassing the SQLAlchemyObjectType you don't get the warning. If you uncomment the commented out section you will get the warning.
|
Nah, that’s probably because your |
@zmwangx I added the ConnectionField to the Model and it still does it. Uncomment the comments and it will throw the warning. this is the entire schema.
|
I'm talking about auto-generated connection field from your SQLA model, not a SQLAlchemyConnectionField you explicitly add to the query (which does not go through the default connection field factory — you already explicitly instantiated the field). A default connection field is created when you have, say, a one to many relationship on your SQLA model. You don't show your database models here, but say we have two very simple tables: Base = declarative_base()
class UserModel(Base):
__tablename__ = "user"
id = Column(Integer, primary_key=True)
transactions = relationship("TransactionModel", back_populates="user")
class TransactionModel(Base):
__tablename__ = "transaction"
id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey("user.id"), nullable=False)
user = relationship("UserModel", back_populates="transactions")
class User(SQLAlchemyObjectType):
class Meta:
model = UserModel
interfaces = (Node,)
class Transaction(SQLAlchemyObjectType):
class Meta:
model = TransactionModel
interfaces = (Node,) Then the generated Update: I made a mistake when I said "the |
Hi everyone, I introduced that warning in this PR when refactoring Apologies for the confusion. |
Here is the fix. Thanks for reporting the issue. |
I thought I had figured it out but obviously not. I'm still confused...this stuff seems very hand wavy (magical stuff going on in the background) and its really confusing me. For example, was getting this (#153) error when I had "Connection" at the end of a class name. This type of stuff makes things extremely difficult to understand whats going on when its valid Python and its simply due to all the stuff going on in the background. While not an error, its something thats not very obvious of whats going on and makes things extremely difficult to understand and debug. But I digress, I'm still confused about this... You stated:
Based off this statement it should not throw the warning in my example when you uncomment those lines in my example above correct? Here is what I'm seeing with your example...
Commented out |
I tried a million ways to figure out how to instantiate a connection field factory via SQLAlchemyObjectType.Meta.connection_field_factory to get this warning to stop spamming me to death... |
Yeah, me too. I'm still trying to figure out why its throwing the messages. Its really not clear to me on how/why its happening. The fluffery in the library seems to be confusing me. Luckily it will be fixed in the next release. |
This will be merged tomorrow |
@jnak appreciate it! I saw your message that it will be fixed. I was just talking to @zmwangx on why the messages were appearing in different circumstances. I know the whole point would be moot after it gets fixed but just to know whats going on behind the scenes is why I was asking. The whole graphene-sqlalchemy library seems to be doing some magic in the background depending on if it detects different things so I just was wanting to be more aware of what was going on. |
Probably not a good place to discuss how graphene-sqlalchemy works, but guess I'll respond one more time (everyone else: sorry about the noise). @vaskokj Use introspection[1] to look at generated schema (GraphiQL Docs panel is another way to consume the introspection data, but sometimes it's nice to see everything at once). It should help you a lot.
That's because you also commented out all references to Forget about class Query(ObjectType):
user = Field(User) # Field is graphene.Field
transaction = Field(Transaction) And play with field exclusion: class Transaction(SQLAlchemyObjectType):
class Meta:
model = TransactionModel
interfaces = (Node,)
exclude_fields = ("user",) # Try to turn this on and off Again, use introspection. You should understand what I meant. Finally, I found the source code fairly readable, so you can always just read the code to understand what's going on. [1] https://graphql.org/learn/introspection/ (I made a mistake in my original comment and posted an update.) |
The fix is now available on I will document |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topics referencing this issue. |
I'm using graphene-sqlalchemy version 2.2.0 and I'm getting lots of
createConnectionField is deprecated and will be removed in the next major version. Use SQLAlchemyObjectType.Meta.connection_field_factory instead.
warnings.Is there any example on how to configure this connection_field_factory? Are there any default factories? So far I couldn't find any example using this new feature on the project site.
Thank you!
The text was updated successfully, but these errors were encountered: