(s *gqlScaffolder, field string, args map[string]any)
| 142 | func (introSchema) typeName() string { return "__Schema" } |
| 143 | |
| 144 | func (introSchema) resolve(s *gqlScaffolder, field string, args map[string]any) any { |
| 145 | named := func(def *ast.Definition) any { |
| 146 | if def == nil { |
| 147 | return nil |
| 148 | } |
| 149 | return introType{ast.NamedType(def.Name, nil)} |
| 150 | } |
| 151 | switch field { |
| 152 | case "description": |
| 153 | return optional(s.schema.Description) |
| 154 | case "types": |
| 155 | names := make([]string, 0, len(s.schema.Types)) |
| 156 | for name := range s.schema.Types { |
| 157 | names = append(names, name) |
| 158 | } |
| 159 | sort.Strings(names) |
| 160 | list := []introObject{} |
| 161 | for _, name := range names { |
| 162 | list = append(list, introType{ast.NamedType(name, nil)}) |
| 163 | } |
| 164 | return list |
| 165 | case "queryType": |
| 166 | return named(s.schema.Query) |
| 167 | case "mutationType": |
| 168 | return named(s.schema.Mutation) |
| 169 | case "subscriptionType": |
| 170 | return named(s.schema.Subscription) |
| 171 | case "directives": |
| 172 | names := make([]string, 0, len(s.schema.Directives)) |
| 173 | for name := range s.schema.Directives { |
| 174 | names = append(names, name) |
| 175 | } |
| 176 | sort.Strings(names) |
| 177 | list := []introObject{} |
| 178 | for _, name := range names { |
| 179 | list = append(list, introDirective{s.schema.Directives[name]}) |
| 180 | } |
| 181 | return list |
| 182 | } |
| 183 | return nil |
| 184 | } |
| 185 | |
| 186 | // introType is a type reference. A non-null or list type wraps another type. |
| 187 | type introType struct{ t *ast.Type } |
nothing calls this directly
no test coverage detected