MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / UpdateGQLSchema

Function UpdateGQLSchema

edgraph/server.go:166–191  ·  view source on GitHub ↗

UpdateGQLSchema updates the GraphQL and Dgraph schemas using the given inputs. It first validates and parses the dgraphSchema given in input. If that fails, it returns an error. All this is done on the alpha on which the update request is received. Then it sends an update request to the worker, whic

(ctx context.Context, gqlSchema,
	dgraphSchema string)

Source from the content-addressed store, hash-verified

164// it returns an error. All this is done on the alpha on which the update request is received.
165// Then it sends an update request to the worker, which is executed only on Group-1 leader.
166func UpdateGQLSchema(ctx context.Context, gqlSchema,
167 dgraphSchema string) (*pb.UpdateGraphQLSchemaResponse, error) {
168 var err error
169 parsedDgraphSchema := &schema.ParsedSchema{}
170
171 if !x.WorkerConfig.AclEnabled {
172 ctx = x.AttachNamespace(ctx, x.RootNamespace)
173 }
174 // The schema could be empty if it only has custom types/queries/mutations.
175 if dgraphSchema != "" {
176 op := &api.Operation{Schema: dgraphSchema}
177 if err = validateAlterOperation(ctx, op, NeedAuthorize); err != nil {
178 return nil, err
179 }
180 if parsedDgraphSchema, err = parseSchemaFromAlterOperation(ctx, op.Schema); err != nil {
181 return nil, err
182 }
183 }
184
185 return worker.UpdateGQLSchemaOverNetwork(ctx, &pb.UpdateGraphQLSchemaRequest{
186 StartTs: worker.State.GetTimestamp(false),
187 GraphqlSchema: gqlSchema,
188 DgraphPreds: parsedDgraphSchema.Preds,
189 DgraphTypes: parsedDgraphSchema.Types,
190 })
191}
192
193// validateAlterOperation validates the given operation for alter. The
194// structural checks (field set, health, drop consistency, mutations-allowed)

Callers 2

ResolveMethod · 0.92
alterMethod · 0.70

Calls 5

AttachNamespaceFunction · 0.92
validateAlterOperationFunction · 0.85
GetTimestampMethod · 0.80

Tested by

no test coverage detected