Love using dry-system but I’ve come across what I believe is a load order issue and wondering how others deal with it. I’m currently adding the graphql gem to my plain ruby project. The structure is like this
Resolvers are what actions a graphql query, and the types are just objects with whatever fields (very similar to a dry-struct actually)
Inside a resolver class are the types that will be used for the specific query. Defined like this
graphql_name "User" type Types::User, null: true description "Returns a user for the specified user id"
What I find is every time I boot my application I get the following exception:
NameError: uninitialized constant Types::User
This is because it tries to load the resolvers first, hits the line where the type is defined and can’t figure it out as the types were not loaded first. I can fix this by requiring the type classes at the top of the file but that doesn’t seem right. Isn’t one of the benefits of dry system the fact that I shouldn’t have to require a bunch of files at the top of each class?
when I rename the types folder to apple, they get loaded first, so I have no issue with booting. This is obviously not an ideal workaround. I’ve actually had to do this for other graphql classes and put them in a folder called grapql/zebra to be loaded last, when ideally they shouldn’t need to be in a folder at all. In the meantime I will go back to requiring necessary files at the top of a class, but would love a better resolution, or just a better understanding if this is the way it is.
Tried to be as verbose as possible, let me know if more information is required. Thanks.