
542 N.W.2d 62 (1996)
Roger and Linda VRIEZE, Appellants,
v.
NEW CENTURY HOMES, INC., et al., City of Plymouth, Respondents,
John Doe and Mary Doe, Defendants.
No. C0-95-1587.
Court of Appeals of Minnesota.
January 16, 1996.
*63 S. Todd Rapp, Bloomington, for Vrieze.
E. Curtis Roeder, Hanson, Lulic & Krall, Minneapolis, for New Century Homes, et al.
Allen D. Barnard, Caryn S. Glover, Best Flanagan, P.L.L.P., Minneapolis, for City of Plymouth.
Considered and decided by KALITOWSKI, P.J., and KLAPHAKE and FOLEY, JJ.

OPINION
DANIEL F. FOLEY, Judge.[*]
Appellants Roger and Linda Vrieze challenge the trial court's granting of summary judgment in favor of respondent City of Plymouth on appellants' claims for damages and declaratory judgment stemming from the city's allegedly negligent failure to enforce *64 approved provisions of an issued building permit, which negligence appellants claim resulted in damage to their property. The trial court held that the city was entitled to discretionary immunity for its actions and decisions pertaining to the building permit.

FACTS
Respondent New Century Homes, Inc. (New Century) is the owner of land adjacent to appellants' property in the city of Plymouth. In March 1993, New Century submitted a plan to the city to develop its tract into a subdivision.
As a part of its subdivision development plan, New Century applied for a building permit to build a retaining wall between its property and appellants' property, to screen the subdivision from appellants' electrical contracting business. Based on New Century's submitted construction plans, the city issued a building permit containing detailed conditions for the wall's construction. Additionally, when New Century began development of the subdivision, the city's approved grading plan for New Century's lot permitted only minor grading alterations on the property adjacent to appellants' land where New Century planned to build the retaining wall.
After the wall was constructed, the city learned that the wall did not conform to the plans submitted or to the building permit. Specifically, the trial court found, the wall was shorter in length than specified and constructed of a different material; appellants further allege that the wall was too high, that it lacked adequate foundation, and that in building the wall New Century had substantially altered the grading of the land in violation of the approved grading plan for the lot.
After learning of the wall's nonconformities, the city inspected the wall and required New Century to construct a swale along the lots' border in order to channel surface water away from appellants' property in the manner that a longer wall would have rechanneled water. New Century complied with the city's request. The city then sent an expert to evaluate the wall's construction specifically with regard to the material used to build it. That expert identified several problems with the wall that required attention before the wall could be certified. The city asked New Century to correct the items set forth in the expert's report, which it did. The city then certified the wall.
Appellants sued New Century, New Century's executive officer, and the city, claiming that the wall caused excess drainage of surface water onto their property and that they believed the wall might collapse. Appellants sought a declaratory judgment directing the city "to implement and enforce its codes and ordinances, and specifically, to enforce the provisions of the approved grading plan for [the subdivision tract and] its codes and ordinances relative to the safe and lawful construction of the said retaining wall." Appellants also sought damages for the "diminution in the rightful and reasonable value of the[ir] property" caused by the city's negligent failure to enforce its building permit and approved grading plan.
The city made a rule 12 motion to dismiss for failure to state a claim,[1] invoking immunity from appellants' tort action under the statutory discretionary immunity doctrine. The trial court granted the city's motion and dismissed appellant's action on grounds that the city was immune from liability under the doctrine of discretionary immunity.

ISSUE
Is the City of Plymouth entitled to discretionary immunity from appellants' action alleging that the city negligently failed to enforce its issued building permit and approved grading plan?


*65 ANALYSIS
Whether a city's acts are discretionary or ministerial in nature is a legal question. Snyder v. City of Minneapolis, 441 N.W.2d 781, 786 (Minn.1989). This court is not bound by the trial court's decision on purely legal questions, but must review such questions de novo. Frost-Benco Elec. Ass'n v. Minnesota Pub. Utils. Comm'n, 358 N.W.2d 639, 642 (Minn.1984). The city bears the burden of showing that its act is within the discretionary immunity exception to municipal liability. Nusbaum v. Blue Earth County, 422 N.W.2d 713, 722 n. 6 (Minn. 1988).

I. The Discretionary Immunity Doctrine
The question before us is one of first impression in Minnesota: Is a city's effort or lack of effort to enforce a building permit after the permit is issued legally distinguishable, for purposes of applying discretionary immunity, from the actual issuance of such a permit, which the supreme court has repeatedly held to be discretionary? Minnesota courts have extended discretionary immunity protection to acts similar to the issuance of a building permit, but have never explicitly addressed whether modifying or failing to enforce a permit is discretionary or ministerial. The trial court held in this case that the city's approval of the final retaining wall, though apparently in conflict with its previously issued building permit, was a discretionary act. We affirm the trial court's decision.
By way of introduction, the State Tort Claims Act waived established principles of governmental immunity by requiring a municipality to pay compensation where a private person would be liable. Holmquist v. State, 425 N.W.2d 230, 231 (Minn.1988). This waiver is subject to exceptions, including the exception for "loses caused by the municipality's "performance or the failure to exercise or perform a discretionary function or duty, whether or not the discretion is abused." Minn.Stat. § 466.03, subd. 6 (1994). The discretionary immunity exception has drawn efforts by Minnesota's appellate courts to distinguish discretionary municipal acts from nondiscretionary or ministerial ones.
The two Minnesota Supreme Court cases that extensively address the policy rationale behind the discretionary immunity exception are Cairl v. State, 323 N.W.2d 20 (Minn.1982) and Holmquist. In Cairl, the court said:
The [discretionary immunity] exemption from tort liability recognizes that the courts, through the vehicle of a negligence action, are not an appropriate forum to review and second-guess the acts of government which involve "the exercise of judgment or discretion." * * * The problem is * * * that almost every act involves some measure of discretion, and yet undoubtedly not every act of government is entitled to discretionary immunity. * * * Accordingly, we must examine the nature of the decisionmaking process to determine whether discretionary immunity obtains. * * * [Decisions involving] the balancing of complex and competing factors comprising "a discretionary choice between alternatives" [invoke the immunity exception].
Cairl, 323 N.W.2d at 23-24. In Holmquist, the court appeared to tighten slightly the standard set forth in Cairl. Holmquist emphasized that discretionary immunity requires not only that the municipal act or decision involve a balancing of complex factors, but also that imposing liability for the act or decision would pose a threat to some municipal policy:
In Cairl, we held that the [municipal] decision to release [a prisoner] was protected by the discretionary function exception, not simply because it involved a professional evaluation of complex and competing factors, but because the threat of liability would frustrate the State's policy of open-door treatment of the mentally ill. * * * It is, however, the evaluation and weighing of social, political, and economic considerations underlying public policy decisions, not the application of scientific and technical skills in carrying out established policy, which invokes the discretionary function exception affording governmental immunity. *66 Holmquist, 425 N.W.2d at 232-33. In sum, to find the discretionary immunity doctrine applicable, courts must determine both that the municipal act or decision at issue involves the professional evaluation of complex and competing factors and that exposing the municipality to tort liability would undermine public policy.

II. Discretionary Immunity for the Issuance of Building Permits
In 1970, the supreme court held that the issuance of a building permit is a discretionary act and that municipalities are immune from tort liability for issuing permits. Anderson v. City of Minneapolis, 287 Minn. 287, 289, 178 N.W.2d 215, 217 (1970). After Cairl and Holmquist were decided, the court reaffirmed the holding of Anderson, stating:
[W]e note that more than eighteen years have passed since our decision in Anderson, ample time for the legislature to have corrected any misapprehension this court may have entertained in Anderson regarding legislative intent to protect municipalities from liability in the issuance of building permits. Accordingly, we have no occasion to question the continuing viability of Anderson.

Snyder, 441 N.W.2d at 787. While discretionary immunity case law has not explicitly described the public policy that would be jeopardized if municipalities could be liable for issuing building permits, the supreme court has stated elsewhere that building permits "are not meant to be an insurance policy by which the municipality guarantees that each building is built in compliance with the building codes and zoning codes." Hoffert v. Owatonna Inn Towne Motel, 293 Minn. 220, 223, 199 N.W.2d 158, 160 (1972) (discussing city's duty to use due care in issuing permits).
Appellants argue that the issuance of a building permit is distinguishable from what they characterize as the "duty to enforce" such permits, and they assert that the latter function is merely ministerial. Appellants claim that the trial court did not understand this distinction, but the court clearly understood the
distinction and found it unpersuasive: Plaintiffs do not challenge the building permits, per se. Plaintiffs, however, challenge the subsequent approval of modifications  with respect to the retaining wall  to the original permits. * * * Plymouth's building inspector's subsequent modification does not fall within the realm of an operational decision.
We agree with the trial court and conclude that subsequent approval of modifications to a building permit constitute a discretionary act.
On several occasions, Minnesota courts have indicated that where a municipal decision or act resembles the issuance of a building permit, that decision or act is discretionary. For example, in Wilson v. Ramacher, 352 N.W.2d 389, 393 (Minn.1984), the supreme court held that the issuance of permits to put fill on land was a discretionary act because it resembled in process the issuance of building permits held to be discretionary in Anderson. Similarly, in Masonick v. J.P. Homes, 494 N.W.2d 910 (Minn.App.1993), this court applied discretionary immunity to the issuance of certificates of occupancy, stating that "the decisionmaking process involved * * * is similar to that involved in the issuance of a building permit." Id. at 913. Finally, this court recently applied discretionary immunity to a municipality's issuance of a permit to construct a sewage treatment system because "the procedure followed in deciding whether to grant a permit to construct a sewage treatment system is similar to that involved in deciding whether to grant a building permit." McNamara v. McLean, 531 N.W.2d 911, 914 (Minn.App.1995).
While none of the above cases directly control the question before us, they do indicate that the rationale of Anderson applies to analogous situations. Like the municipal action at issue in McNamara, the procedure of approving modifications to a building permit is "similar to that involved in deciding whether to grant a building permit  both attempt to ensure that minimum safety requirements are met." Id.
Indeed, applying the policy rationale underlying the discretionary immunity doctrine as described in Cairl, a municipal decision to accept construction modifications *67 involves "the balancing of complex and competing factors comprising `a discretionary choice between alternatives.'" Cairl, 323 N.W.2d at 24. Furthermore, as required by Holmquist, imposing municipal liability for such decisions would threaten a public policy; if cities were immune from liability for issuing or failing to issue permits, but liable for failing to enforce those permits, it is difficult to see how cities could avoid being made guarantors of problem-free construction in the manner the supreme court found problematic in Hoffert, 199 N.W.2d at 160.
Appellants also argue that even if municipal tort liability is entirely precluded in this case by the discretionary immunity doctrine, appellants are entitled to go to court on their declaratory judgment claim because "[t]his cause of action does not even assert tort liability, but simply seeks to have Respondent compelled to perform the duties it clearly has not performed." Appellants' position seems to be that they can demand declaratory judgment without asserting any underlying legal theory of recovery. But of course some recovery theory must underlie a declaratory judgment demand and appellants' Complaint asserted only a tort recovery theory. If the city cannot be liable to appellants in tort, it cannot be forced either to pay appellants' damages or to take action to correct the "negligence" appellants allege.

DECISION
Reversing the trial court's decision in this case would restrict the doctrine of discretionary immunity in a manner counter to public policy and the development of case law in this area. We therefore affirm the trial court order and hold that municipal action in connection with a building permit subsequent to its issuance, such as approval of modifications of that permit or requests that the developer make adjustments to meet the permit's terms or safety regulations, is discretionary and therefore shielded from liability in the same way that the original issuance of a permit is discretionary.
Affirmed.
NOTES
[*]  Retired judge of the Minnesota Court of Appeals, serving by appointment pursuant to Minn. Const. art. VI, § 2.
[1]  Ordinarily, issues of immunity like those raised in this case would be decided after discovery and not simply on the basis of a rule 12 motion. Nonetheless, because in this case extra complaint material came in without objection from appellants and appellants submitted their own extra complaint material, the trial court properly considered respondents' rule 12 motion as a rule 56 motion for summary judgment. See Minn. R.Civ.P. 12.02 ("If, on a motion asserting the defense that the pleading fails to state a claim upon which relief can be granted, matters outside the pleading are presented to and not excluded by the court, the motion shall be treated as one for summary judgment and disposed of as provided in Rule 56 * * *.").
