Add formatter.WithNonIntrospectionBuiltin#415
Conversation
|
Thanks, and sorry for the format hassles! I recently altered the .golangci-lint so you should be able fix any formatting by just running: golangci-lint fmt --config=../.golangci.yaml .Which if you don't have golangci-lint installed (and don't mind YOLO'ing it!) you can use this script: #!/bin/bash
# this will format the code locally
function is_bin_in_path {
builtin type -P "$1" &> /dev/null
}
function fmtall {
export GOBIN="$HOME/go/bin"
mkdir -p "$GOBIN"
! is_bin_in_path golangci-lint && GOBIN=$HOME/go/bin curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $GOBIN latest
export PATH="$GOBIN:$PATH"
golangci-lint fmt --config=./golangci.yaml .
}
fmtallOr, you can use golangci-lint's recommended installation instructions and do things one of the normal, safe (and sane) ways. 😅 |
|
Thanks for the pointer! Installed Just ran and pushed the last commit. However, I still see this error in CI, which looks like an existing issue in master's CI result |
|
To help unblock this PR, I took a stab at the existing linter errors in this repos. #416 should take care of them with no behavior change. Let me know if the fix is reasonable~ This PR will unblock an upcoming launch that we have. If it takes a bit to get in, we may consider creating a temporary folk. Hopefully, we can avoid it. Appreciate your timely feedback and reviews! PS: Love those linter improvements. Our internal tooling flagged them as well when we import them~ |
|
@StevenACoffman Let me know if there are anything I can do to get this PR unblocked~ Thanks a lot! |
another linter error
|
@fredzqm This was great! I'm sorry, I was actually away travelling for a week and am just catching up! |
|
@fredzqm I cut a v2.5.32 release including this feature https://github.com/vektah/gqlparser/releases/tag/v2.5.32 |
|
Nice! Thanks you @StevenACoffman for unblocking me!🙏🙏 |
formatter.WithBuiltinuses two criteria to determine what is a builtin schema:A) The
Definition.Builtinor.Position.Src.BuiltInB) The type name or field name starts with
__, commonly associated with Graphql's introspection API.I ran into a case where I want the formatter to print all builtin types, fields and directives without
__typename,__schema, so the end result is still considered a valid Graphql. Duplicating builtin scalars and ID is considered valid in graphql-js, but not the introspection fields.The existing option
formatter.WithBuiltinwill render types & fields that match either A) or B).The new option
formatter.WithNonIntrospectionBuiltinwill render types & fields that match A), but still exclude introspection fields.I have: