MCPcopy
hub / github.com/dgraph-io/dgraph / Resolve

Method Resolve

graphql/admin/schema.go:34–69  ·  view source on GitHub ↗
(ctx context.Context, m schema.Mutation)

Source from the content-addressed store, hash-verified

32}
33
34func (usr *updateSchemaResolver) Resolve(ctx context.Context, m schema.Mutation) (*resolve.Resolved, bool) {
35 glog.Info("Got updateGQLSchema request")
36
37 input, err := getSchemaInput(m)
38 if err != nil {
39 return resolve.EmptyResult(m, err), false
40 }
41
42 // We just need to validate the schema. Schema is later set in `resetSchema()` when the schema
43 // is returned from badger.
44 schHandler, err := schema.NewHandler(input.Set.Schema, false)
45 if err != nil {
46 return resolve.EmptyResult(m, err), false
47 }
48
49 // we don't need the correct namespace for validation, so passing the Galaxy namespace
50 if _, err = schema.FromString(schHandler.GQLSchema(), x.RootNamespace); err != nil {
51 return resolve.EmptyResult(m, err), false
52 }
53
54 resp, err := edgraph.UpdateGQLSchema(ctx, input.Set.Schema, schHandler.DGSchema())
55 if err != nil {
56 return resolve.EmptyResult(m, err), false
57 }
58
59 return resolve.DataResult(
60 m,
61 map[string]interface{}{
62 m.Name(): map[string]interface{}{
63 "gqlSchema": map[string]interface{}{
64 "id": query.UidToHex(resp.Uid),
65 "schema": input.Set.Schema,
66 "generatedSchema": schHandler.GQLSchema(),
67 }}},
68 nil), true
69}
70
71func (gsr *getSchemaResolver) Resolve(ctx context.Context, q schema.Query) *resolve.Resolved {
72 var data map[string]interface{}

Callers

nothing calls this directly

Calls 11

GQLSchemaMethod · 0.95
DGSchemaMethod · 0.95
EmptyResultFunction · 0.92
NewHandlerFunction · 0.92
FromStringFunction · 0.92
UpdateGQLSchemaFunction · 0.92
DataResultFunction · 0.92
UidToHexFunction · 0.92
getSchemaInputFunction · 0.85
InfoMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected