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

Function NewServers

graphql/admin/admin.go:588–613  ·  view source on GitHub ↗

NewServers initializes the GraphQL servers. It sets up an empty server for the main /graphql endpoint and an admin server. The result is mainServer, adminServer.

(withIntrospection bool, globalEpoch map[uint64]*uint64,
	closer *z.Closer)

Source from the content-addressed store, hash-verified

586// NewServers initializes the GraphQL servers. It sets up an empty server for the
587// main /graphql endpoint and an admin server. The result is mainServer, adminServer.
588func NewServers(withIntrospection bool, globalEpoch map[uint64]*uint64,
589 closer *z.Closer) (IServeGraphQL, IServeGraphQL, *GraphQLHealthStore) {
590 gqlSchema, err := schema.FromString("", x.RootNamespace)
591 if err != nil {
592 x.Panic(err)
593 }
594
595 resolvers := resolve.New(gqlSchema, resolverFactoryWithErrorMsg(errNoGraphQLSchema))
596 e := globalEpoch[x.RootNamespace]
597 mainServer := NewServer()
598 mainServer.Set(x.RootNamespace, e, resolvers)
599
600 fns := &resolve.ResolverFns{
601 Qrw: resolve.NewQueryRewriter(),
602 Arw: resolve.NewAddRewriter,
603 Urw: resolve.NewUpdateRewriter,
604 Drw: resolve.NewDeleteRewriter(),
605 Ex: resolve.NewDgraphExecutor(),
606 }
607 adminResolvers := newAdminResolver(mainServer, fns, withIntrospection, globalEpoch, closer)
608 e = globalEpoch[x.RootNamespace]
609 adminServer := NewServer()
610 adminServer.Set(x.RootNamespace, e, adminResolvers)
611
612 return mainServer, adminServer, mainHealthStore
613}
614
615// newAdminResolver creates a GraphQL request resolver for the /admin endpoint.
616func newAdminResolver(

Callers 1

setupServerFunction · 0.92

Calls 10

FromStringFunction · 0.92
PanicFunction · 0.92
NewFunction · 0.92
NewQueryRewriterFunction · 0.92
NewDeleteRewriterFunction · 0.92
NewDgraphExecutorFunction · 0.92
NewServerFunction · 0.85
newAdminResolverFunction · 0.85
SetMethod · 0.65

Tested by

no test coverage detected