Skip to content

Commit

Permalink
fix(GraphQL): Fix graphql flaky tests which were caused by receiving …
Browse files Browse the repository at this point in the history
…extra schema updates (#7329)

Don't update GraphQL schema if an older version of schema key is received.
  • Loading branch information
JatinDev543 committed Jan 20, 2021
1 parent 8fbdca6 commit cc506cc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions graphql/admin/admin.go
Expand Up @@ -418,6 +418,7 @@ func (g *GraphQLHealthStore) updatingSchema() {
type gqlSchema struct {
ID string `json:"id,omitempty"`
Schema string `json:"schema,omitempty"`
Version uint64
GeneratedSchema string
}

Expand Down Expand Up @@ -522,12 +523,13 @@ func newAdminResolver(
}

newSchema := &gqlSchema{
ID: query.UidToHex(pk.Uid),
Schema: string(pl.Postings[0].Value),
ID: query.UidToHex(pk.Uid),
Version: kv.GetVersion(),
Schema: string(pl.Postings[0].Value),
}
server.mux.RLock()
if newSchema.Schema == server.schema.Schema {
glog.Infof("Skipping GraphQL schema update as the new schema is the same as the current schema.")
if newSchema.Version <= server.schema.Version || newSchema.Schema == server.schema.Schema {
glog.Infof("Skipping GraphQL schema update, new badger key version is %d, the old version was %d.", newSchema.Version, server.schema.Version)
server.mux.RUnlock()
return
}
Expand Down

0 comments on commit cc506cc

Please sign in to comment.