Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    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
    dzhelezov
    @dzhelezov
    Hi! Have the following question: I have some properties in my model classes which I want to store as jsonb by at the same type map to non-scalar ObjectTypes. I was able to achieve that by combining @WarthogField('json') @ColumType('jsonb') and @Field() decorators. Almost everything works smoothly out of the box (including the really cool json support in whereInputs), except for the fact that the output skips this field as it's non-scalar. I had to hack it around by manually adding that field to the fields array pass down to the services, is there a more elegant way to do that? Sorry if the q is too messy
    Dan Caddigan
    @goldcaddy77
    Hi, why doesn't the JsonField decorator work exactly? Do you have a code sample?
    dzhelezov
    @dzhelezov
    Well it does, by I want a more comprehensive type at the GraphQL side. Here is my code:
    @ObjectType()
    export class EventParam {
      @Field()
      type!: string
    
      @Field()
      name?: string
    
      @Field(() => GraphQLJSON)
      value!: AnyJsonField
    }
    export class Foo extends BaseModel {
    @Field(() => [EventParam], { nullable: true })
      @Column('jsonb')
      @WarthogField('json', { nullable: true })
      params?: EventParam[]
    }
    Dan Caddigan
    @goldcaddy77
    Oh gotcha. So you're looking to nest a complex object into a single field.
    Dan Caddigan
    @goldcaddy77
    I'll look into adding support for this. Would you always want it to be jsonb or could you see it ever spreading the fields into the DB individually?
    Dan Caddigan
    @goldcaddy77
    @dzhelezov If I'm reading this correctly, your JSON type is an array of EventParams? That's not valid JSON, right? Shouldn't it be something like
    Dan Caddigan
    @goldcaddy77
    {
      "params": EventParam[]
    }
    Dan Caddigan
    @goldcaddy77

    @dzhelezov is this what you were looking for? goldcaddy77/warthog#412

    This is how you'd set it up in your model: https://github.com/goldcaddy77/warthog/pull/412/files#diff-984f57b34defd9f4be76f9d2e7979a8cR34

    I was hoping to be able to be able to take care of adding the type-graphql "InputType" inside my "ObjectType" decorator and not need to declare both, but for some reason I couldn't make it work. Let me know what you think in the PR.

    dzhelezov
    @dzhelezov
    Yes, looks like exactly what I needed
    and actually array of EventParams sers/desers to JSON w/o any problems, so I am not sure if there's any difference with Array<EventParam>, though it's prob cleaner

    I'll look into adding support for this. Would you always want it to be jsonb or could you see it ever spreading the fields into the DB individually?

    I think for the time being jsonb would be totally fine, as any other field can be turned into a regular field of the base class

    Dan Caddigan
    @goldcaddy77
    Oh, you must be using a json column then, not jsonb
    If an array will properly land in the column
    dzhelezov
    @dzhelezov
    I see, will look into that. On a separate topic: what are your node, and estarget versions? For some reason I can't get the compiled server version, it either silently dies (with node 14) or (with node 12) complains about import statements at runtime, even though it compiles. Seemlike like the default target does not like the import statements, but I couldn't find the right combination of the transpiler to make it work
    Dan Caddigan
    @goldcaddy77
    Node 14 is supported yet - 12 should work. What happens when you try 10?
    dzhelezov
    @dzhelezov

    I get `import {
    ^

    SyntaxError: Unexpected token {`

    in one of my model files
    ```
    SyntaxError: Unexpected token { at Module._compile (internal/modules/cjs/loader.js:703:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10) at Module.load (internal/modules/cjs/loader.js:628:32) at Function.Module._load (internal/modules/cjs/loader.js:555:12) at Module.require (internal/modules/cjs/loader.js:666:19) at require (internal/modules/cjs/helpers.js:16:16) at /Users/zhelezov/hydra/substrate-query-framework/index-server/node_modules/typeorm/util/DirectoryExportedClassesLoader.js:41:39 at Array.map (<anonymous>) at Object.importClassesFromDirectories (/Users/zhelezov/hydra/substrate-query-framework/index-server/node_modules/typeorm/util/DirectoryExportedClassesLoader.js:41:10) at ConnectionMetadataBuilder.buildEntityMetadatas (/Users/zhelezov/hydra/substrate-query-framework/index-server/node_modules/typeorm/connection/ConnectionMetadataBuilder.js:50:97)
    Full stack trace
    Dan Caddigan
    @goldcaddy77
    Can you create a git issue for this and I'll take a deeper look?
    Dan Caddigan
    @goldcaddy77
    @dzhelezov Please file a git issue - I suspect you haven't specified WARTHOG_DB_MIGRATIONS in .env
    dzhelezov
    @dzhelezov
    Hi! Sorry for the late reply, I think I have finally figured it out thanks to your hint. I had db/migrations and it seems it was messing with the tsconfig. So after some try-and-error the following set-up seems to work: 1) add db//*.ts to tsconfig sources 2) set `WARTHOG_DB_MIGRATIONS=dist/db/migrations//*.js` instead of the default
    Let me know if you'd like to have at as a github issue
    dzhelezov
    @dzhelezov
    Opened up another (unrelated) issue here: goldcaddy77/warthog#422
    Dan Caddigan
    @goldcaddy77
    I actually did some work this weekend on the production setup
    Check out config and scripts in those 2 PRs
    dzhelezov
    @dzhelezov
    thanks, so one can actually use a ready-to-use CI ?
    Dan Caddigan
    @goldcaddy77
    What do you mean by that? In Warthog starter I use CircleCI
    dzhelezov
    @dzhelezov
    Yeah I just mean these and the heroku scripts come quite handy
    Dan Caddigan
    @goldcaddy77
    Oh great, glad they're helpful! I'll continue to build them up in the starter project.
    dzhelezov
    @dzhelezov
    Hi! Any plans on goldcaddy77/warthog#422 ?
    No rush, just curious if it'd make sense to make PR ourselves or you're already working on iy
    Dan Caddigan
    @goldcaddy77
    I haven't started work, so feel free to put in a PR and we can get it merged