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)
| 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. |
| 588 | func 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. |
| 616 | func newAdminResolver( |
no test coverage detected