Comments (4)
I’d like to know the foreign table name when building the manyRelationByKeys name
I believe this is already possible:
manyRelationByKeys(detailedKeys: Keys, table: string, schema: ?string) {
return camelCase(
`${this.pluralize(
this.tableName(table, schema)
)}-by-${detailedKeys
.map(key => this.column(key.column, key.table, key.schema))
.join("-and-")}`
);
},
the table
and schema
arguments refer to the target table, and the keys contain the source table and schema that the keys come from.
use case, column site on table discussion targets a row in table site
I believe you're saying this:
create table site (
id serial not null primary key
);
create table discussion (
id serial not null primary key,
site int not null references site(id)
)
because there is only one key and that this key is named as the target table, I’d like to call it "site" instead of "discussionsBySite"
On the Discussion
type, if set up as above, there should be a field siteBySite
which references the remote table site
using the local column site
. If you rename this to site
it will clash with the column that is named site
- you may need to combine this, then with the pgColumnFilter that's being introduced in #73 so that the column is never added to the schema. Personally I'd have named the column site_id
and then having the relation renamed to site
would cause no issues.
(which is weird on its own, it should be sitesByDiscussions, shouldn’t it?)
The relation discussionsBySite
would be the reverse relation, found on the Site
type, and represents the one-to-many nature of the relationship (one site has many discussions). In this case it is returning a list of discussions
(target table, plural) that are identified by site
(target table column since it's a reverse relation); hence discussionsBySite
.
from graphile-engine.
the table and schema arguments refer to the target table, and the keys contain the source table and schema that the keys come from.
My bad, they all refer to the foreign table because it's a reverse relation. I'd definitely consider a PR that added the local table and schema as additional arguments to that inflector 👍
from graphile-engine.
sorry I posted this too fast and made some mistakes / wasn’t very clear.yes, I’m talking about the field added by the PgBackwardRelationPlugin on the Site type.
you’re absolutely right about the schema and the thing about pgColumnFilter that’s exactly why I wanted to filter fields in the first place :)
should the 2nd and 3rd arguments be kept as they are always the same as in the key columns ? (or maybe keys should contain only the column names?) that would be a BC break. tell me and I’ll make a PR
from graphile-engine.
that’s exactly why I wanted to filter fields in the first place :)
😳 I should spend more time reading people's usernames
should the 2nd and 3rd arguments be kept as they are always the same as in the key columns ? (or maybe keys should contain only the column names?) that would be a BC break. tell me and I’ll make a PR
I think the existing values should be kept because then it mirrors the forward relation; it's annoying to have 5 arguments but ¯\_(ツ)\_/¯
I probably should have gone with a named hash API instead. Oh well 😅
from graphile-engine.
Related Issues (20)
- InitObject is typed wrong HOT 4
- [graphql-parse-resolve-info] Fix types or example HOT 3
- Custom functions for `nodeId` in `NodePlugin` HOT 2
- Add depth traversal to `simplifyParsedResolveInfoFragmentWithType` HOT 2
- No Way to Access Request From Resolvers? HOT 1
- [graphile-build]: Types for Build Don't Match Source HOT 4
- graphql-parse-resolve-info scalar fields HOT 2
- Pagination cursors not working for tables with at least one bigint component HOT 6
- Modify column SQL select HOT 1
- graphile/subscriptions-lds does not trigger on DELETE if subscription contains only edges
- Project depends on vulnerable version of jsonwebtoken HOT 2
- graphql-parse-resolve-info - What to do to get the same output like graphql-fields? HOT 5
- Don't silently swallow exceptions in resolveNode HOT 2
- alias a column at mutation time only? HOT 2
- Type with array property triggers error HOT 10
- Error using PG client: "We only support PG clients from a PG pool..." HOT 4
- pg-pubsub call to removeListener looks like it will not work HOT 3
- Provide a type guard to distinguish between ResolveTree and FieldsByTypeName HOT 2
- Multiple services resulting in duplicate codecs for simple types HOT 1
- Defining two types with the same schema should be allowed HOT 1
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 graphile-engine.