-
Notifications
You must be signed in to change notification settings - Fork 178
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
Move non-protocol options like table & where to the params sub-key #2081
Conversation
✅ Deploy Preview for electric-next ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
On extending types — we have this issue with Electric Cloud where |
Examples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always though of what you're calling PostgresParams
as the ShapeDefinition
. I understand the reasoning that where
clauses are specific to SQL/relational databases and not the shape, and that other shapes will have different models, but we also don't know what the API is going to look like two steps down the road.
I also think that except for replica
all the parameters belong to the class of SQLParams
, where MySQL
, etc would also fit. I think this can be addresses with the hierarchy of types and only handled when necessary, but if we're trying to communicate support for multiple databases in the future I think this would be a nice thing to model.
I'm sharing my two cents, but I am happy to accept the changes as they are
The distinction is between the "Shape Definition" and "Shape Log Traversing Definition" (heh) — so yeah |
I've not looked into the actual code but i'll share my two-cents about the new |
I'd say this is cleaner now — what's been interesting to me building demo apps is that I basically never use the pg-specific options — because I'm always using an API to proxy shape requests, I just construct URLs generally to get the shapes I need with perhaps a custom parameter or two. So given proxies, the specific http parameters that the Electric API require already aren't special — they're just one of many possible Shape APIs that will exist. I also don't think we're very far off from supporting other sources. I prompt-coded one last week that was pretty close. |
I agree that the motivation of supporting non PG sources is a long way off and I would argue we should have an explicit way of defining a shape, via a shape definition. I think the move to having what is currently the shape definition under a params key is harmless but I’m not sure the motivation behind it holds. |
My 2 cents... I think this is good. 'params' works at the url params level, and is compatible with any proxy. If we one day add a shape def in json, it's likely a "shape" param and would be under options.params.shape. And maybe a shortcut to it via options.shape. Maybe we let users add any key+value to params to add to the url? I do think we need to start thinking what a more expressive definition of a shape is, speculatively, to guide what this api should look like. Include, joins, remapping, even aggregates, are things we may want to do in future. It's worth while before we evolve this api much further. 👍 |
Fix #2079
Electric's TypeScript client is currently tightly coupled to PostgreSQL-specific options in its
ShapeStreamOptions
interface. As Electric plans to support multiple data sources in the future, we need to separate protocol-level options from source-specific options.Changes
PostgresParams
type to define PostgreSQL-specific parameters:table
: The root table for the shapewhere
: Where clauses for the shapecolumns
: Columns to include in the shapereplica
: Whether to send full or partial row updatesShapeStreamOptions
interface to theparams
sub-keyParamsRecord
type to include PostgreSQL parametersShapeStream
class to handle parameters from theparams
objectMigration Example
Before:
After: