githubv4 icon indicating copy to clipboard operation
githubv4 copied to clipboard

Provide tag to ignore field

Open vgough opened this issue 8 years ago • 5 comments

Other golang serializers tend to use "-" as an ignore tag. Eg, json : json:"-"

I've found an ugly workaround for githubql:

var query struct {
  ...
  IgnoreThisField int `graphql:"# ignore\n"`
}

vgough avatar Nov 22 '17 23:11 vgough

Thanks for the suggestion/feature request.

That makes sense. encoding/json sets a good precedent for this with its json:"-".

I'll think about this a bit, and most likely go with graphql:"-" as well.

dmitshur avatar Nov 23 '17 00:11 dmitshur

A question so I can understand this better. Can you elaborate on your use case and how you came up with this need? Given that query usually maps to a GraphQL query pretty directly, why did you need/want to have fields there that are meant to not be a part of the GraphQL query?

dmitshur avatar Nov 23 '17 00:11 dmitshur

I had been doing some post processing of the results before sending them to an html template renderer. I've since reorganized my code to avoid mutating the query result, or copying to another representation for the places where the query struct doesn't fit well with the renderer.

vgough avatar Nov 23 '17 04:11 vgough

I see. If I understand correctly, you no longer have a need for this, is that right? If so, I'm happy to defer dealing with this issue until a concrete need comes up. It would give us more time to think about it, and keeps the project simpler until then.

dmitshur avatar Nov 23 '17 07:11 dmitshur

Hey @dmitshur 👋🏼

Is this something you're still considering adding to the package?

crqrdotcom avatar Feb 08 '22 13:02 crqrdotcom