-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat: Column.excludeFieldFromQuery, exclude field but keep fields array #1217
feat: Column.excludeFieldFromQuery, exclude field but keep fields array #1217
Conversation
…lue in the parameter signature
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1217 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 245 245
Lines 17246 17277 +31
Branches 6232 6247 +15
=========================================
+ Hits 17246 17277 +31 ☔ View full report in Codecov by Sentry. |
hmm I'm wondering if it wouldn't be better to do the inverse instead? For example keep using |
From how I've been using TypeScript, interfaces and documentation, I think it's handy they similar as they appear close together when looking for similar behaviours. eg all the other However, one consideration is that
=> The entire column, and by extension, the field, are excluded from the query. The behaviour is consistent with the settings Conversely
is not logically consistent as the entire column is excluded and the Would you ever put the two options together? Probably not... but at least with the former the behaviour isn't ambiguous? I'll leave it to you to decide :) |
Another property name could be |
Yes that was my intention, I thought of that approach because that is how a TypeScript
hmm not crazy about the name either haha... but in that case then we might as well keep your first approach but I'm wondering if we should have 3 options then? Let me know if you have any other suggestions or if I should go ahead with merging? |
@@ -108,6 +108,9 @@ export interface Column<T = any> { | |||
/** Default to false, which leads to exclude the column title from the Grid Menu. */ | |||
excludeFromGridMenu?: boolean; | |||
|
|||
/** Defaults to false, which leads to exclude the field property, but including the fields property, from the query (typically a backend service query) */ |
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.
can you use backticks on the column options, when we use that it shows them as code in the editor as well
/** ... which leads to exclude the `field` property, but including the `fields` property
Could you also update the next option I created as well. I started using this approach not long ago, I didn't know VSCode also shows code this way :) see example below, thought it's hard to see, the field has a color background
@@ -98,7 +98,9 @@ export class GraphqlService implements BackendService { | |||
const columnIds: string[] = []; | |||
if (columnDefinitions && Array.isArray(columnDefinitions)) { | |||
for (const column of columnDefinitions) { | |||
columnIds.push(column.field); | |||
if (!column.excludeFieldFromQuery) { | |||
columnIds.push(column.field); |
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.
could you apply the same logic in the OData Service as well, they should have the same feature as much as possible
@Harsgalt86 I want to release a new version this weekend (Saturday or Sunday), I would rather wait for this PR to be updated but I don't want to wait too long 😉 |
Sorry, only just saw this. I did look at updating the odata service before
opening the PR but didn't see any code directly adding 'fields' in the
buildQuery function nor were there any unit tests directly testing the same
way the graphql.spec was. I'll take another look with fresh eyes, hopefully
tomorrow morning if I get some spare time, otherwise I will on Monday. It
would be good to get this merged in for the next release, but don't want to
hold you up either :)
…On Sat, 25 Nov 2023, 9:18 am Ghislain B., ***@***.***> wrote:
@Harsgalt86 <https://github.com/Harsgalt86> I want to release a new
version this weekend (Saturday or Sunday), I would rather wait for this PR
to be updated but I don't want to wait too long 😉
—
Reply to this email directly, view it on GitHub
<#1217 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BCEFSVHXK3A472AMNWHVJVDYGEP5PAVCNFSM6AAAAAA7YVGLSCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRWGEZDEMJXHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
oh right I just remembered now that it's only for GraphQL, we didn't need it for OData because most of the time in OData and REST API you pull all the fields at once, that's kinda why we migrated to GraphQL. So it's all good, if you could just do the other little changes I asked, that would be great. I |
All done. |
-- Situation --
From the GraphQL, we may have a fragment that is as such
We want the
firstName
andlastName
from the server, butfullName
will be populated locally through policyhttps://www.apollographql.com/docs/react/local-state/managing-state-with-field-policies/#querying
In the table, we want the column to display the fullname
-- Problem --
The generated query by slickgrid attempts to request all 3 properties
firstName
,lastName
andfullName
.We want to only request
firstName
andlastName
-- Solution --
There already exists a column propety
excludeFromQuery
that excludes the entire columnDef from the buildQuery. This PR introduces another propertyexcludeFieldFromQuery
which excludescolumn.field
but still addscolumn.fields
to the queryThe result is the following column definition
Side note: The
queryField
property basically solves the same underlying problem but specifically for filtering and sorting.