Check Graphql Schema Status after update

Hi,

Is there a way to check when dgraph is ready to serve a new graphql schema after an update of the schema is performed?
I’m running into in an issue that when I query the current schema after updating the schema, some of the new types that I’ve added are not returned.

Thanks

Can you check if all instances are capable of reach each other? pls double check.

In general 30 seconds after the cluster is up. I’d wait a bit more.

There is only one instance, the issue is not when the cluster is starting, it occurs when getting the current schema, after just having updated the graphql schema.

Can you share details? like logs, prints and so on.

Sorry for the delay, I noticed the issue because I’m dynamically updating the schema and then trying to perform a mutation(of the automatically generated by dgraph) on new types, and from time to time I get an error saying that the mutation does not exist.
I’ve developed the most basic test that I could to replicate the issue:

package gql_test

import (
	"context"
	"fmt"
	"strings"
	"testing"

	"github.com/machinebox/graphql"
	"gotest.tools/assert"
)

func TestUpdateSchemaDelay(t *testing.T) {
	cl := graphql.NewClient("http://localhost:8080/admin")

	schemaDef := generateTypes(1, 2000)

	fmt.Println("Updating schema...")
	err := UpdateSchema(cl, schemaDef)
	assert.NilError(t, err)

	fmt.Println("Getting schema...")
	generatedSchema, err := GetCurrentSchema(cl)
	assert.NilError(t, err)

	assert.Assert(t, strings.Contains(generatedSchema, "updatePerson2000"))

	schemaDef += generateTypes(2001, 2000)
	assert.Assert(t, strings.Contains(schemaDef, "Person4000"))
	fmt.Println("Updating schema...")
	err = UpdateSchema(cl, schemaDef)
	assert.NilError(t, err)

	fmt.Println("Getting schema...")
	generatedSchema, err = GetCurrentSchema(cl)
	assert.NilError(t, err)

	assert.Assert(t, strings.Contains(generatedSchema, "updatePerson4000"))

}

func generateTypes(start, count int) string {
	schemaDef := ""
	for i := start; i < start+count; i++ {
		schemaDef += fmt.Sprintf(`
			type Person%v {
				name: String @search(by: [term])
				createdAt: DateTime @search(by: [day])
				intValue: Int64 @search(by: [int64])
				picks: [Int64]
			}
		`, i)
	}
	return schemaDef
}

func GetCurrentSchema(cl *graphql.Client) (string, error) {
	req := graphql.NewRequest(`
		{
			getGQLSchema{
				schema
				generatedSchema
			}
		}
	`)
	var response interface{}
	err := cl.Run(context.Background(), req, &response)
	if err != nil {
		return "", fmt.Errorf("failed getting current schema, error: %v", err)
	}
	gqlSchema := response.(map[string]interface{})["getGQLSchema"]

	if gqlSchema == nil {
		return "", nil
	}
	schema := gqlSchema.(map[string]interface{})["generatedSchema"].(string)
	if schema == "" {
		return "", nil
	}

	return schema, nil
}

func UpdateSchema(cl *graphql.Client, schema string) error {
	req := graphql.NewRequest(`
		mutation($schema: String!) {
			updateGQLSchema(
				input: {
					set: {
						schema:$schema
					}
				}
			){
				gqlSchema {id}
			}
		}
	`)
	req.Var("schema", schema)

	err := cl.Run(context.Background(), req, nil)
	if err != nil {
		return fmt.Errorf("failed updating schema, error: %v", err)
	}

	return nil
}

I get the following result:

Updating schema...
Getting schema...
Updating schema...
Getting schema...
--- FAIL: TestUpdateSchemaDelay (12.58s)
    schema-delay_test.go:40: assertion failed: expression is false: strings.Contains(generatedSchema, "updatePerson4000")
FAIL
exit status 1
FAIL	github.com/sebastianmontero/hypha-document-cache-gql-go/gql	12.580s