shurcooL / githubv4

Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://docs.github.com/en/graphql).
MIT License
1.11k stars 89 forks source link

Provide tag to ignore field #26

Open vgough opened 6 years ago

vgough commented 6 years ago

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"`
}
dmitshur commented 6 years ago

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 commented 6 years ago

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?

vgough commented 6 years ago

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.

dmitshur commented 6 years ago

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.

jcrqr commented 2 years ago

Hey @dmitshur 👋🏼

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