Comments (7)
Hello, I would love to see the documentation "here's a good set of defaults for hasura".
from genqlient.
Hi @benjaminjkraft, thanks so much for the attention to this issue. I'm happy to answer any questions and pitch in on fine-tuning any tests you can think up.
I currently have a mid-size hasura schema with ~50 tables and a 35,720 line GQL schema dump
I'm fortunate that most of my queries are done on the front-end and only sensitive admin-level ones are performed in go on the server. I currently have 12 mutations and 27 queries in my server-side code.
With the changes discussed in #149 and the use_struct_references: true
config option coupled with numerous directives like: @genqlient(for: "account_insert_input.created", pointer: true, omitempty: true)
it's been working well for me.
The largest issue I'm now facing is that I have timestamp columns mapped to time.Time
but that causes mutations to insert 0
as a default value unless I add directives like the above. Then the trigger on the table sees the 0 and doesn't set the value to now()
as it should. It's not quite risen to the level of digging in and making a PR for it, but it's on the TODO list.
Looking at my config, I'm also reminded that I fought with jsonb columns and finally just ended up using 'interface{}` and parsing internally. I only have one or two columns of jsonb, so it's not been a large issue for me.
from genqlient.
AFAICT, The Hasura GraphQL Engine serves a Relay-based schema for PostgreSQL tables which have a primary key defined.
As a result, I would think #78 for Relay specific issues is relevant.
Better support for Relay APIs, in general, would help not only Hasura, but Github API, and a number of other providers.
from genqlient.
Hi @benjaminjkraft , thanks a lot for paying attention to Hasura users, really appreciate it! :)
hasura seems to now consider explicit null an error at least for all inputs if I'm understanding right?
Not necessarily. Explicit null will not be an error for the following scenario. Instead, it will set the field to NULL validly. If we want it to fallback to "DEFAULT" value, however, we would need to omit the field altogether.
First of all, one theory -- already very possible -- is to say you just want to #260 (comment). This is obviously less flexible, which in the common case is arguably good but doesn't scale well
This is a very good observation! I think this is the answer for Hasura user. A client library I'm using in Flutter (https://github.com/heftapp/graphql_codegen) behaves this way and so far I haven't encountered issues using it with Hasura. Indeed it generates quite a lot of structures because it generates 1:1 structure for each of the GraphQL input, but I found it quite nice because it's easier to wrap my head around it.
from genqlient.
I'm not sure whether it's backed by Hasura or not, but I'm seeing similar problems when querying the graphql interface of https://www.datocms.com/, specifically the explicit vs implicit null
, but also the complex/self-referential types which make application of per-type directives much harder
from genqlient.
Apologies if this has been reported elsewhere... I see a lot of value around polymorphic bulk mutations with conditionally present batch insert inputs... I wrote more about this problem here.
from genqlient.
I've also had to set use_struct_references: true
and optional: pointer
to make inputs to mutations for Braintree's / PayPal's GraphQL work reasonably. https://github.com/braintree/graphql-api/blob/master/schema.graphql
And now that I've gotten to queries, oh boy is this head scratching. If I'm understanding correctly, the issue might be similar to some of them that you're observing with Hasura?
edit:
Ooh I might be simple minded or lack of docs, but GitHub Copilot seemed to get me the deeply nested query I needed right after making this comment.
from genqlient.
Related Issues (20)
- config option `optional` is not validated HOT 1
- Add Go 1.20 to tests
- Drop Go <1.18 HOT 3
- Global omitempty option HOT 12
- Make it easier to integration test config options
- Premarshal struct does not maintain JSON tags (omitempty) HOT 6
- Handling enums with strings that have variations of character casing HOT 2
- genqlient: command not found HOT 2
- Nullable list in optional pointer mode generates non-pointer slice HOT 2
- invalid character '<' looking for beginning of value HOT 4
- Inline fragments not working with `use_struct_references: true` and `pointer: optional` HOT 4
- codegen error: 'data' redeclared in this block HOT 1
- Split `TestGenerateWithConfig` cases
- Binding to a type in the same package as generated code produces invalid output HOT 4
- Cannot use Go keywords as variable names in mutation. HOT 1
- panic: runtime error: invalid memory address -- generate.go:403 HOT 4
- `# @genqlient(for: "Input.nonOptionalField", omitempty: false)` not working HOT 4
- Test that all snapshots are used
- Is there a way to access the raw http response? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from genqlient.