Skip to content
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

Add support for default Hasura types #93

Closed
pelletier197 opened this issue Jun 7, 2022 · 4 comments · Fixed by #103
Closed

Add support for default Hasura types #93

pelletier197 opened this issue Jun 7, 2022 · 4 comments · Fixed by #103
Labels
enhancement New feature or request

Comments

@pelletier197
Copy link
Collaborator

pelletier197 commented Jun 7, 2022

Default Hasura types should be supported by query generation factories by default

    {
        _text: "loremipsum",
        bigint: 1000,
        date: "2022-03-06T08:23:45.000Z",
        float8: 0.1,
        geography: { type: "Point", coordinates: [0, 0] },
        geometry: { type: "Point", coordinates: [0, 0] },
        jsonb: {},
        numeric: 1,
        smallint: 42,
        timestamp: "2022-03-06T08:23:45.000Z",
        timestamptz: "2022-03-06T08:23:45.000Z",
        uuid: "a12ce80c-42e3-4149-89cc-4afda30e5e7f",
      }

See #92 for more details.

@pelletier197 pelletier197 added the enhancement New feature or request label Jun 7, 2022
@pelletier197 pelletier197 changed the title Add support for default Hasana types Add support for default Hasura types Jun 8, 2022
@pelletier197
Copy link
Collaborator Author

Looking at Hasura types, some of the example here seem inacurate. For example, bigint seems to be a string. Would need to double check these.

@efstathiosntonas
Copy link

@pelletier197 you're right but the query accepts both integer and string as a value

this will work:

query MyQuery($total_likes: bigint = 3) {
  comment(where: {total_comment_likes: {_gte: $total_likes}}) {
    author_id
  }
}

also this does work:

query MyQuery($total_likes: bigint = "3") {
  comment(where: {total_comment_likes: {_gte: $total_likes}}) {
    author_id
  }
}

Hasura has some weird types but we should stick with their docs, we should treat binint as a String.

@pelletier197
Copy link
Collaborator Author

pelletier197 commented Jun 8, 2022

Alright. I'll be honest though, it' s a little weird to implement some of these types as string. For instance, another user could have a bigint type, and it would be more reasonable for this user to use a number as input.

I think it makes sense to implement some of these with a natural default value.

        _text: "loremipsum",
        bigint: 1000000,
        float8: 0.1,
        numeric: 1,
        smallint: 42,
        timestamp: "2022-03-06T08:23:45.000",
        timestamptz: "2022-03-06T08:23:45.000Z",
        uuid: "a12ce80c-42e3-4149-89cc-4afda30e5e7f",
        jsonb: {}
        date: "1996-03-05"

However, some of these make less sense:

  • geometry, geography are two objects that could perfectly exist in any other API and look totally different.
  • jsonb is super specific to Postgres, but might be okay to add
  • date should be only yyyy-dd-mm (and that's also what Hasura returns anyways).

So I would implement all of these using the natural way if you're fine with it. If the type is ever not like you'd want too, you can always override it. Does that seem fair to you?

@efstathiosntonas
Copy link

Yeah, seems totally fair!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants