-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow graphql types and fields to be gated behind feature flags (#69)
* add graphql features and required features for field * lots o tests * stricter checking of object/interface fields * support feature requirements for types * add tests
- Loading branch information
Showing
41 changed files
with
410 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package schema | ||
|
||
type FeatureSet map[string]struct{} | ||
|
||
func NewFeatureSet(features ...string) FeatureSet { | ||
fs := make(FeatureSet, len(features)) | ||
for _, feature := range features { | ||
fs[feature] = struct{}{} | ||
} | ||
return fs | ||
} | ||
|
||
func (s FeatureSet) Has(feature string) bool { | ||
_, ok := s[feature] | ||
return ok | ||
} | ||
|
||
func (s FeatureSet) IsSubsetOf(other FeatureSet) bool { | ||
for feature := range s { | ||
if _, ok := other[feature]; !ok { | ||
return false | ||
} | ||
} | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package schema | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestFeatureSet(t *testing.T) { | ||
s := NewFeatureSet("a", "b", "c") | ||
assert.True(t, s.Has("a")) | ||
assert.True(t, s.Has("b")) | ||
assert.True(t, s.Has("c")) | ||
assert.False(t, s.Has("d")) | ||
|
||
s2 := NewFeatureSet("a", "b") | ||
assert.True(t, s2.IsSubsetOf(s)) | ||
assert.False(t, s.IsSubsetOf(s2)) | ||
} | ||
|
||
func TestFeatureSet_Nil(t *testing.T) { | ||
var s FeatureSet | ||
assert.False(t, s.Has("a")) | ||
|
||
s2 := NewFeatureSet("a", "b") | ||
assert.True(t, s.IsSubsetOf(s2)) | ||
assert.False(t, s2.IsSubsetOf(s)) | ||
|
||
var s3 FeatureSet | ||
assert.True(t, s.IsSubsetOf(s3)) | ||
assert.True(t, s3.IsSubsetOf(s)) | ||
} |
Oops, something went wrong.