Exemplo n.º 1
0
func getOperationRootType(
	schema typs.QLSchema,
	operation *lang.OperationDefinition,
) *typs.QLObject {
	switch operation.Operation {
	case lang.OperationQuery:
		return schema.GetQueryType()
	case lang.OperationMutation:
		murationType := schema.GetMutationType()
		if murationType == nil {
			panic(lang.NewQLError(
				"Schema is not configured for mutations",
				[]lang.INode{operation}))
		}
		return murationType
	default:
		panic(lang.NewQLError(
			"Can only execute queries and mutation",
			[]lang.INode{operation}))
	}
}