File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Sources/GraphQL/Validation Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -96,3 +96,38 @@ func visit(
96
96
)
97
97
return context. errors
98
98
}
99
+
100
+ /**
101
+ * Utility function which asserts a SDL document is valid by throwing an error
102
+ * if it is invalid.
103
+ *
104
+ * @internal
105
+ */
106
+ func assertValidSDL( documentAST: Document ) throws {
107
+ let errors = validateSDL ( documentAST: documentAST)
108
+ if !errors. isEmpty {
109
+ throw GraphQLError (
110
+ message: errors. map { $0. message } . joined ( separator: " \n \n " ) ,
111
+ locations: [ ]
112
+ )
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Utility function which asserts a SDL document is valid by throwing an error
118
+ * if it is invalid.
119
+ *
120
+ * @internal
121
+ */
122
+ func assertValidSDLExtension(
123
+ documentAST: Document ,
124
+ schema: GraphQLSchema
125
+ ) throws {
126
+ let errors = validateSDL ( documentAST: documentAST, schemaToExtend: schema)
127
+ if !errors. isEmpty {
128
+ throw GraphQLError (
129
+ message: errors. map { $0. message } . joined ( separator: " \n \n " ) ,
130
+ locations: [ ]
131
+ )
132
+ }
133
+ }
You can’t perform that action at this time.
0 commit comments