88
99#include " graphqlservice/GraphQLGrammar.h"
1010#include " graphqlservice/GraphQLParse.h"
11- #include " graphqlservice/GraphQLService.h"
11+ #include " graphqlservice/GraphQLResponse.h"
12+ #include " graphqlservice/GraphQLSchema.h"
1213
1314#include < array>
1415#include < cstdio>
@@ -222,7 +223,8 @@ using OperationTypeList = std::vector<OperationType>;
222223
223224struct GeneratorClient
224225{
225- const std::string clientFilename;
226+ const std::string schemaFilename;
227+ const std::string requestFilename;
226228 const std::string filenamePrefix;
227229 const std::string clientNamespace;
228230};
@@ -235,11 +237,9 @@ struct GeneratorPaths
235237
236238struct GeneratorOptions
237239{
238- const std::optional< GeneratorClient> customClient ;
240+ const GeneratorClient client ;
239241 const std::optional<GeneratorPaths> paths;
240242 const bool verbose = false ;
241- const bool separateFiles = false ;
242- const bool noStubs = false ;
243243 const bool noIntrospection = false ;
244244};
245245
@@ -256,7 +256,6 @@ class Generator
256256 std::string getHeaderDir () const noexcept ;
257257 std::string getSourceDir () const noexcept ;
258258 std::string getHeaderPath () const noexcept ;
259- std::string getObjectHeaderPath () const noexcept ;
260259 std::string getSourcePath () const noexcept ;
261260
262261 void visitDefinition (const peg::ast_node& definition);
@@ -321,12 +320,16 @@ class Generator
321320 response::Value _value;
322321 };
323322
324- void validateClient ();
323+ void validateSchema ();
325324 void fixupOutputFieldList (OutputFieldList& fields,
326325 const std::optional<std::unordered_set<std::string_view>>& interfaceFields,
327326 const std::optional<std::string_view>& accessor);
328327 void fixupInputFieldList (InputFieldList& fields);
329328
329+ void validateQuery () const ;
330+ std::shared_ptr<schema::Schema> buildSchema () const ;
331+ void addTypesToSchema (const std::shared_ptr<schema::Schema>& schema) const ;
332+
330333 std::string_view getCppType (std::string_view type) const noexcept ;
331334 std::string getInputCppType (const InputField& field) const noexcept ;
332335 std::string getOutputCppType (const OutputField& field) const noexcept ;
@@ -341,34 +344,31 @@ class Generator
341344 bool outputSource () const noexcept ;
342345 void outputObjectImplementation (
343346 std::ostream& sourceFile, const ObjectType& objectType, bool isQueryType) const ;
344- void outputObjectIntrospection (std::ostream& sourceFile, const ObjectType& objectType) const ;
345347 std::string getArgumentDefaultValue (
346348 size_t level, const response::Value& defaultValue) const noexcept ;
347349 std::string getArgumentDeclaration (const InputField& argument, const char * prefixToken,
348350 const char * argumentsToken, const char * defaultToken) const noexcept ;
349351 std::string getArgumentAccessType (const InputField& argument) const noexcept ;
350352 std::string getResultAccessType (const OutputField& result) const noexcept ;
351353 std::string getTypeModifiers (const TypeModifierStack& modifiers) const noexcept ;
352- std::string getIntrospectionType (
353- std::string_view type, const TypeModifierStack& modifiers) const noexcept ;
354354
355- std::vector<std::string> outputSeparateFiles () const noexcept ;
355+ static std::shared_ptr<const schema::BaseType> getIntrospectionType (
356+ const std::shared_ptr<schema::Schema>& schema, std::string_view type,
357+ TypeModifierStack modifiers, bool nonNull = true ) noexcept ;
356358
357- static const std::string_view s_introspectionNamespace;
358359 static const BuiltinTypeMap s_builtinTypes;
359360 static const CppTypeMap s_builtinCppTypes;
360361 static const std::string_view s_scalarCppType;
361362 static const std::string s_currentDirectory;
362363
363364 const GeneratorOptions _options;
364- const bool _isIntrospection;
365365 std::string_view _clientNamespace;
366366 const std::string _headerDir;
367367 const std::string _sourceDir;
368368 const std::string _headerPath;
369- const std::string _objectHeaderPath;
370369 const std::string _sourcePath;
371- peg::ast _ast;
370+ peg::ast _schema;
371+ peg::ast _request;
372372
373373 SchemaTypeMap _clientTypes;
374374 PositionMap _typePositions;
0 commit comments