by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Elias Jackson
    @FOSSforlife
    I'm trying to use the example test in warthog-starter, and it looks like it's not actually mocking the DB, it's using the same one as development. I see a mention of a "warthog.sqlite.tmp" file in testHelpers but I don't see that being created.
    Elias Jackson
    @FOSSforlife
    Seems like it might have something to do with this: https://github.com/goldcaddy77/warthog#mockdbconnection-has-been-removed
    Dan Caddigan
    @goldcaddy77
    @FOSSforlife that’s right I’ve removed the need for the SQLite database. It was previously used in codegen and testing, but it’s not used for either anymore
    For tests, we should use a separate test database
    Look at warthogs tests for how I do they there
    Elias Jackson
    @FOSSforlife
    Ok I was able to get a test db working by just passing in a new env variable for WARTHOG_DB_DATABASE in the npm script.
    Things are mostly working well but there's one issue: Is there a way to test field resolvers using the generated binding?
    Dan Caddigan
    @goldcaddy77
    Cool. Would setting that to Postgres in the .env file fix it?
    The field resolvers are accessible in the binding
    Elias Jackson
    @FOSSforlife
    It would, but that would mean I'd need to manage a separate .env file for testing. I might do that eventually if there's more variables to change
    And awesome, I didn't know you could plug straight graphql into those binding functions
    Dan Caddigan
    @goldcaddy77
    @FOSSforlife can you file that issue against warthog-starter ?
    Elias Jackson
    @FOSSforlife
    Will do
    Elias Jackson
    @FOSSforlife

    I've been following a tutorial on youtube/github to get proper jwt authorization working with a refresh token, and it seems like I need access to the "response" parameter in the context in order to set the cookie, not just request: https://github.com/benawad/jwt-auth-example/blob/master/server/src/index.ts#L62

    But Warthog only exposes the request, from what I understand: https://github.com/goldcaddy77/warthog/blob/master/src/core/server.ts#L35

    Any way around this? I'll admit I'm kind of a noob when it comes to authentication

    Dan Caddigan
    @goldcaddy77
    Can you add this as a Git issue too for folks that might run into the same situation?
    You need to use express middleware
    You can do this using the onBeforeGraphQLMiddleware or onAfterGraphQLMiddleware server options - https://github.com/goldcaddy77/warthog/blob/a02a237b58269fd22b219c31b7a106a4d42af815/src/core/server.ts#L47
    They’ll expose the express app
    And you can add middleware
    Which will expose res
    Elias Jackson
    @FOSSforlife
    Awesome! I will try that out tonight and write an issue
    Dan Caddigan
    @goldcaddy77
    Sounds good
    dzhelezov
    @dzhelezov
    Hi! Thanks for the lib! Are there any plans to support enum fields in the cli ?
    Dan Caddigan
    @goldcaddy77
    Hey, no prob! I wasn’t planning on it, just because the syntax would be complicated, but if you have a proposal I’d be happy to review and take a PR or add to my list. Feel free to open a Git issue and we can keep discussing there
    dzhelezov
    @dzhelezov
    Ok I see! Implementing the enums indeed requires a bit more ejs juggling as far as i can tell. In our project we use warthog-cli internally to generate the warthog model files from a special schema file, so our use-case is quite narrow. It seems then that for our needs generating the warthog model files directly (from e.g. a Mustache template) would be more straightforward than invoking warthog-cli.
    Dan Caddigan
    @goldcaddy77
    Can you suggest an API for the CLI command with generate?
    dzhelezov
    @dzhelezov
    Not sure if I understand correctly, but in our case it just seems like a single line CLI is just not expressive enough to support all the feature we need (or may need in the future). Our scaffolding is based on a GraphQL-like schema file instead which ofc gives more power to express names, relationships and so on
    so while one can come up with some CLI convention for enums (like field:enum:MY_ENUM) it becomes harder to support a growing list of features
    Dan Caddigan
    @goldcaddy77
    Interesting, so is everything auto-generated from that file?
    Dan Caddigan
    @goldcaddy77
    Yeah I could support some Enum syntax like that in the generate command - it wouldn’t be too bad in the ejs
    dzhelezov
    @dzhelezov

    Interesting, so is everything auto-generated from that file?

    Yes, correct. The idea is that the user defines a schema and gets a 'batteries included' GraphQL server (+ we have some extra project specific twists on top of that)

    Yeah I could support some Enum syntax like that in the generate command - it wouldn’t be too bad in the ejs

    I think the main inconvenience is that the enum should be already defined somewhere (one can ofc put the enum definition in the same cli args too, but it then gets quite bulky)

    Btw, another related question regarding enums: one of the examples says that the enum class should be defined and exported in the same class as the entity. What happens if several entities reference the same enum?
    Dan Caddigan
    @goldcaddy77

    Yes, correct. The idea is that the user defines a schema and gets a 'batteries included' GraphQL server (+ we have some extra project specific twists on top of that)

    Interesting - would love to talk about your use-case sometime on a Zoom call if you’re willing.

    Dan Caddigan
    @goldcaddy77

    Btw, another related question regarding enums: one of the examples says that the enum class should be defined and exported in the same class as the entity. What happens if several entities reference the same enum?

    Good question. It should be fine. Pls try and let me know if you hit any issues

    dzhelezov
    @dzhelezov
    Sure thing! Always up for a chat
    Dan Caddigan
    @goldcaddy77
    Please shoot me an email at goldcaddy77@gmail.com!
    amine
    @amine187
    Hi, I'm asking if there are any plans to add a decorator to check if the user isn't logged in the decorator throw an authentication error, if yes just continue with the query or the mutation
    Dan Caddigan
    @goldcaddy77
    Leave the arguments empty and it will just check that there is a logged in user (assuming you put your user in context)
    amine
    @amine187
    Cool, that's what I'm talking about. thanks
    Dan Caddigan
    @goldcaddy77
    No problem
    dzhelezov
    @dzhelezov

    Btw, another related question regarding enums: one of the examples says that the enum class should be defined and exported in the same class as the entity. What happens if several entities reference the same enum?

    Good question. It should be fine. Pls try and let me know if you hit any issues

    Hi! Spotted the following issue with @EnumField. When I have two separated entities each having a field of the same enum type, the generated file generated/classes.ts imports the class twice. This causes an error, and I think that's b/c the enumfield decorator reexports whatever enum type is imorted

    Dan Caddigan
    @goldcaddy77
    Ahhh that makes sense. I see what’s happening. I need to add an Enum decorator that registers the enum separate from the EnumField (or just make sure the EnumField decorator registers a unique copy per enum)
    @dzhelezov created issue here: goldcaddy77/warthog#372
    Dan Caddigan
    @goldcaddy77
    @dzhelezov I just added info on how to fix to that git issue. Simple fix. Feel free to put in a PR if this is a critical issue on your side.
    dzhelezov
    @dzhelezov
    Thanks a lot for a quick response!
    Dan Caddigan
    @goldcaddy77
    No problem