Skip to content

Commit 063dd54

Browse files
committed
Move more headers into graphqlservice/internal
1 parent a224fea commit 063dd54

26 files changed

+105
-103
lines changed

doc/parsing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ you have another use for a GraphQL parser you could probably make a few small
1717
tweaks to include additional information in the rules or in the resulting AST.
1818
You could also use the grammar without the AST module if you want to handle
1919
the parsing callbacks another way. The grammar itself is defined in
20-
[GraphQLGrammar.h](../include/graphqlservice/GraphQLGrammar.h), and the AST
21-
selector callbacks are all defined in [GraphQLTree.cpp](../src/GraphQLTree.cpp).
20+
[Grammar.h](../include/graphqlservice/internal/Grammar.h), and the AST
21+
selector callbacks are all defined in [SyntaxTree.cpp](../src/SyntaxTree.cpp).
2222
The grammar handles both the schema definition syntax which is used in
2323
`schemagen`, and the query/mutation/subscription operation syntax used in
2424
`Request::resolve` and `Request::subscribe`.

include/RequestLoader.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88

99
#include "GeneratorLoader.h"
1010

11-
#include "graphqlservice/GraphQLGrammar.h"
1211
#include "graphqlservice/GraphQLParse.h"
13-
#include "graphqlservice/GraphQLSchema.h"
1412
#include "graphqlservice/GraphQLService.h"
1513

14+
#include "graphqlservice/internal/Grammar.h"
15+
#include "graphqlservice/internal/Schema.h"
16+
1617
namespace graphql::generator {
1718

1819
using RequestSchemaType = std::shared_ptr<const schema::BaseType>;

include/SchemaLoader.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88

99
#include "GeneratorLoader.h"
1010

11-
#include "graphqlservice/GraphQLGrammar.h"
1211
#include "graphqlservice/GraphQLParse.h"
1312
#include "graphqlservice/GraphQLService.h"
1413

14+
#include "graphqlservice/internal/Grammar.h"
15+
1516
#include <array>
1617
#include <unordered_map>
1718
#include <unordered_set>

include/Validation.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
#ifndef VALIDATION_H
77
#define VALIDATION_H
88

9-
#include "graphqlservice/GraphQLSchema.h"
109
#include "graphqlservice/GraphQLService.h"
1110

11+
#include "graphqlservice/internal/Schema.h"
12+
1213
namespace graphql::service {
1314

1415
using ValidateType = std::optional<std::reference_wrapper<const schema::BaseType>>;

include/graphqlservice/GraphQLGrammar.h renamed to include/graphqlservice/internal/Grammar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef GRAPHQLGRAMMAR_H
1010
#define GRAPHQLGRAMMAR_H
1111

12-
#include "graphqlservice/GraphQLTree.h"
12+
#include "graphqlservice/internal/SyntaxTree.h"
1313

1414
#define TAO_PEGTL_NAMESPACE tao::graphqlpeg
1515

include/graphqlservice/GraphQLSchema.h renamed to include/graphqlservice/internal/Schema.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ class Field : public std::enable_shared_from_this<Field>
307307

308308
GRAPHQLSERVICE_EXPORT static std::shared_ptr<Field> Make(std::string_view name,
309309
std::string_view description, std::optional<std::string_view> deprecationReason,
310-
std::weak_ptr<const BaseType> type, std::vector<std::shared_ptr<const InputValue>>&& args = {});
310+
std::weak_ptr<const BaseType> type,
311+
std::vector<std::shared_ptr<const InputValue>>&& args = {});
311312

312313
// Accessors
313314
GRAPHQLSERVICE_EXPORT std::string_view name() const noexcept;

include/graphqlservice/introspection/Introspection.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
#ifndef INTROSPECTION_H
77
#define INTROSPECTION_H
88

9-
#include "graphqlservice/GraphQLSchema.h"
9+
#include "graphqlservice/internal/Schema.h"
10+
1011
#include "graphqlservice/introspection/IntrospectionSchema.h"
1112

1213
namespace graphql::introspection {

include/graphqlservice/introspection/IntrospectionSchema.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
#ifndef INTROSPECTIONSCHEMA_H
99
#define INTROSPECTIONSCHEMA_H
1010

11-
#include "graphqlservice/GraphQLSchema.h"
12-
#include "graphqlservice/GraphQLService.h"
11+
#include "graphqlservice/internal/Schema.h"
1312

1413
// Check if the library version is compatible with schemagen 3.6.0
1514
static_assert(graphql::internal::MajorVersion == 3, "regenerate with schemagen: major version mismatch");

samples/separate/TodaySchema.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
#ifndef TODAYSCHEMA_H
99
#define TODAYSCHEMA_H
1010

11-
#include "graphqlservice/GraphQLSchema.h"
12-
#include "graphqlservice/GraphQLService.h"
11+
#include "graphqlservice/internal/Schema.h"
1312

1413
// Check if the library version is compatible with schemagen 3.6.0
1514
static_assert(graphql::internal::MajorVersion == 3, "regenerate with schemagen: major version mismatch");

samples/separate_nointrospection/TodaySchema.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
#ifndef TODAYSCHEMA_H
99
#define TODAYSCHEMA_H
1010

11-
#include "graphqlservice/GraphQLSchema.h"
12-
#include "graphqlservice/GraphQLService.h"
11+
#include "graphqlservice/internal/Schema.h"
1312

1413
// Check if the library version is compatible with schemagen 3.6.0
1514
static_assert(graphql::internal::MajorVersion == 3, "regenerate with schemagen: major version mismatch");

samples/unified/TodaySchema.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
#ifndef TODAYSCHEMA_H
99
#define TODAYSCHEMA_H
1010

11-
#include "graphqlservice/GraphQLSchema.h"
12-
#include "graphqlservice/GraphQLService.h"
11+
#include "graphqlservice/internal/Schema.h"
1312

1413
// Check if the library version is compatible with schemagen 3.6.0
1514
static_assert(graphql::internal::MajorVersion == 3, "regenerate with schemagen: major version mismatch");

samples/unified_nointrospection/TodaySchema.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
#ifndef TODAYSCHEMA_H
99
#define TODAYSCHEMA_H
1010

11-
#include "graphqlservice/GraphQLSchema.h"
12-
#include "graphqlservice/GraphQLService.h"
11+
#include "graphqlservice/internal/Schema.h"
1312

1413
// Check if the library version is compatible with schemagen 3.6.0
1514
static_assert(graphql::internal::MajorVersion == 3, "regenerate with schemagen: major version mismatch");

samples/validation/ValidationSchema.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
#ifndef VALIDATIONSCHEMA_H
99
#define VALIDATIONSCHEMA_H
1010

11-
#include "graphqlservice/GraphQLSchema.h"
12-
#include "graphqlservice/GraphQLService.h"
11+
#include "graphqlservice/internal/Schema.h"
1312

1413
// Check if the library version is compatible with schemagen 3.6.0
1514
static_assert(graphql::internal::MajorVersion == 3, "regenerate with schemagen: major version mismatch");

src/CMakeLists.txt

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function(add_bigobj_flag target)
6262
endfunction()
6363

6464
# graphqlpeg
65-
add_library(graphqlpeg GraphQLTree.cpp)
65+
add_library(graphqlpeg SyntaxTree.cpp)
6666
add_library(cppgraphqlgen::graphqlpeg ALIAS graphqlpeg)
6767
target_link_libraries(graphqlpeg PUBLIC taocpp::pegtl)
6868
target_include_directories(graphqlpeg PUBLIC
@@ -116,45 +116,6 @@ if(GRAPHQL_BUILD_SCHEMAGEN OR GRAPHQL_BUILD_CLIENTGEN)
116116
graphqlresponse)
117117
endif()
118118

119-
# schemagen
120-
if(GRAPHQL_BUILD_SCHEMAGEN)
121-
add_executable(schemagen SchemaGenerator.cpp)
122-
add_executable(cppgraphqlgen::schemagen ALIAS schemagen)
123-
target_link_libraries(schemagen PRIVATE generator_util)
124-
add_bigobj_flag(schemagen)
125-
126-
# SchemaGen.rc
127-
if(GRAPHQL_UPDATE_VERSION)
128-
add_dependencies(schemagen update_version_h)
129-
130-
set(SCHEMAGEN_RC_VERSION "${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},0")
131-
set(SCHEMAGEN_RC_VERSION_STR "${PROJECT_VERSION}")
132-
133-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/SchemaGen.rc.in
134-
${CMAKE_CURRENT_BINARY_DIR}/SchemaGen.rc
135-
@ONLY)
136-
137-
add_custom_command(OUTPUT updated_schemagen_rc
138-
COMMAND ${CMAKE_COMMAND} -E copy_if_different SchemaGen.rc ${CMAKE_CURRENT_SOURCE_DIR}/../res
139-
COMMAND ${CMAKE_COMMAND} -E touch updated_schemagen_rc
140-
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/SchemaGen.rc)
141-
142-
add_custom_target(update_schemagen_rc ALL
143-
DEPENDS updated_schemagen_rc)
144-
add_dependencies(schemagen update_schemagen_rc)
145-
endif()
146-
147-
if(WIN32)
148-
add_library(schemagen_version OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/../res/SchemaGen.rc)
149-
target_link_libraries(schemagen PRIVATE schemagen_version)
150-
endif()
151-
152-
install(TARGETS schemagen
153-
EXPORT cppgraphqlgen-targets
154-
CONFIGURATIONS ${GRAPHQL_INSTALL_CONFIGURATIONS}
155-
RUNTIME DESTINATION ${GRAPHQL_INSTALL_TOOLS_DIR}/${PROJECT_NAME})
156-
endif()
157-
158119
# clientgen
159120
if(GRAPHQL_BUILD_CLIENTGEN)
160121
add_executable(clientgen
@@ -196,6 +157,45 @@ if(GRAPHQL_BUILD_CLIENTGEN)
196157
RUNTIME DESTINATION ${GRAPHQL_INSTALL_TOOLS_DIR}/${PROJECT_NAME})
197158
endif()
198159

160+
# schemagen
161+
if(GRAPHQL_BUILD_SCHEMAGEN)
162+
add_executable(schemagen SchemaGenerator.cpp)
163+
add_executable(cppgraphqlgen::schemagen ALIAS schemagen)
164+
target_link_libraries(schemagen PRIVATE generator_util)
165+
add_bigobj_flag(schemagen)
166+
167+
# SchemaGen.rc
168+
if(GRAPHQL_UPDATE_VERSION)
169+
add_dependencies(schemagen update_version_h)
170+
171+
set(SCHEMAGEN_RC_VERSION "${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH},0")
172+
set(SCHEMAGEN_RC_VERSION_STR "${PROJECT_VERSION}")
173+
174+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/SchemaGen.rc.in
175+
${CMAKE_CURRENT_BINARY_DIR}/SchemaGen.rc
176+
@ONLY)
177+
178+
add_custom_command(OUTPUT updated_schemagen_rc
179+
COMMAND ${CMAKE_COMMAND} -E copy_if_different SchemaGen.rc ${CMAKE_CURRENT_SOURCE_DIR}/../res
180+
COMMAND ${CMAKE_COMMAND} -E touch updated_schemagen_rc
181+
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/SchemaGen.rc)
182+
183+
add_custom_target(update_schemagen_rc ALL
184+
DEPENDS updated_schemagen_rc)
185+
add_dependencies(schemagen update_schemagen_rc)
186+
endif()
187+
188+
if(WIN32)
189+
add_library(schemagen_version OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/../res/SchemaGen.rc)
190+
target_link_libraries(schemagen PRIVATE schemagen_version)
191+
endif()
192+
193+
install(TARGETS schemagen
194+
EXPORT cppgraphqlgen-targets
195+
CONFIGURATIONS ${GRAPHQL_INSTALL_CONFIGURATIONS}
196+
RUNTIME DESTINATION ${GRAPHQL_INSTALL_TOOLS_DIR}/${PROJECT_NAME})
197+
endif()
198+
199199
# Common schemagen and clientgen filesystem and Boost dependencies
200200
if(GRAPHQL_BUILD_SCHEMAGEN OR GRAPHQL_BUILD_CLIENTGEN)
201201
set(BOOST_COMPONENTS program_options)
@@ -296,7 +296,7 @@ endif()
296296
# graphqlservice
297297
add_library(graphqlservice
298298
GraphQLService.cpp
299-
GraphQLSchema.cpp
299+
Schema.cpp
300300
Validation.cpp)
301301
add_library(cppgraphqlgen::graphqlservice ALIAS graphqlservice)
302302
target_link_libraries(graphqlservice PUBLIC
@@ -394,49 +394,31 @@ if(GRAPHQL_USE_RAPIDJSON)
394394
endif()
395395
endif()
396396

397-
# graphqljson
398-
if(BUILD_GRAPHQLJSON)
399-
option(GRAPHQL_BUILD_TESTS "Build the tests and sample schema library." ON)
400-
401-
target_link_libraries(graphqljson PUBLIC graphqlintrospection)
402-
403-
install(TARGETS graphqljson
404-
EXPORT cppgraphqlgen-targets
405-
RUNTIME DESTINATION bin
406-
ARCHIVE DESTINATION lib
407-
LIBRARY DESTINATION lib)
408-
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/JSONResponse.h
409-
CONFIGURATIONS ${GRAPHQL_INSTALL_CONFIGURATIONS}
410-
DESTINATION ${GRAPHQL_INSTALL_INCLUDE_DIR}/graphqlservice)
411-
else()
412-
set(GRAPHQL_BUILD_TESTS OFF CACHE BOOL "GRAPHQL_BUILD_TESTS depends on BUILD_GRAPHQLJSON" FORCE)
413-
endif()
414-
415397
install(TARGETS
398+
graphqlclient
399+
graphqlintrospection
416400
graphqlpeg
417401
graphqlresponse
418402
graphqlservice
419-
graphqlintrospection
420-
graphqlclient
421403
EXPORT cppgraphqlgen-targets
422404
RUNTIME DESTINATION bin
423405
ARCHIVE DESTINATION lib
424406
LIBRARY DESTINATION lib)
425407

426408
install(FILES
409+
${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/GraphQLClient.h
427410
${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/GraphQLParse.h
428411
${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/GraphQLResponse.h
429-
${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/GraphQLSchema.h
430412
${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/GraphQLService.h
431-
${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/GraphQLGrammar.h
432-
${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/GraphQLTree.h
433-
${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/GraphQLClient.h
434413
CONFIGURATIONS ${GRAPHQL_INSTALL_CONFIGURATIONS}
435414
DESTINATION ${GRAPHQL_INSTALL_INCLUDE_DIR}/graphqlservice)
436415

437416
install(FILES
438417
${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/Base64.h
418+
${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/Grammar.h
419+
${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/Schema.h
439420
${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/SortedMap.h
421+
${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/SyntaxTree.h
440422
${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/Version.h
441423
CONFIGURATIONS ${GRAPHQL_INSTALL_CONFIGURATIONS}
442424
DESTINATION ${GRAPHQL_INSTALL_INCLUDE_DIR}/graphqlservice/internal)
@@ -447,6 +429,24 @@ install(FILES
447429
CONFIGURATIONS ${GRAPHQL_INSTALL_CONFIGURATIONS}
448430
DESTINATION ${GRAPHQL_INSTALL_INCLUDE_DIR}/graphqlservice/introspection)
449431

432+
# graphqljson
433+
if(BUILD_GRAPHQLJSON)
434+
option(GRAPHQL_BUILD_TESTS "Build the tests and sample schema library." ON)
435+
436+
target_link_libraries(graphqljson PUBLIC graphqlintrospection)
437+
438+
install(TARGETS graphqljson
439+
EXPORT cppgraphqlgen-targets
440+
RUNTIME DESTINATION bin
441+
ARCHIVE DESTINATION lib
442+
LIBRARY DESTINATION lib)
443+
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/JSONResponse.h
444+
CONFIGURATIONS ${GRAPHQL_INSTALL_CONFIGURATIONS}
445+
DESTINATION ${GRAPHQL_INSTALL_INCLUDE_DIR}/graphqlservice)
446+
else()
447+
set(GRAPHQL_BUILD_TESTS OFF CACHE BOOL "GRAPHQL_BUILD_TESTS depends on BUILD_GRAPHQLJSON" FORCE)
448+
endif()
449+
450450
install(EXPORT cppgraphqlgen-targets
451451
NAMESPACE cppgraphqlgen::
452452
DESTINATION ${GRAPHQL_INSTALL_CMAKE_DIR}/${PROJECT_NAME})

src/ClientGenerator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "GeneratorUtil.h"
66

77
#include "graphqlservice/internal/Version.h"
8+
89
#include "graphqlservice/introspection/IntrospectionSchema.h"
910

1011
#ifdef _MSC_VER

src/GeneratorLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "GeneratorLoader.h"
55

6-
#include "graphqlservice/GraphQLGrammar.h"
6+
#include "graphqlservice/internal/Grammar.h"
77

88
#include <algorithm>
99

src/GraphQLService.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// Licensed under the MIT License.
33

44
#include "graphqlservice/GraphQLService.h"
5-
#include "graphqlservice/GraphQLGrammar.h"
5+
6+
#include "graphqlservice/internal/Grammar.h"
67

78
#include "Validation.h"
89

src/RequestLoader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#include "SchemaLoader.h"
66
#include "Validation.h"
77

8-
#include "graphqlservice/introspection/Introspection.h"
8+
#include "graphqlservice/internal/Grammar.h"
99

10-
#include "graphqlservice/GraphQLGrammar.h"
10+
#include "graphqlservice/introspection/Introspection.h"
1111

1212
#include <algorithm>
1313
#include <array>

src/GraphQLSchema.cpp renamed to src/Schema.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
#include "graphqlservice/GraphQLSchema.h"
4+
#include "graphqlservice/internal/Schema.h"
5+
56
#include "graphqlservice/introspection/IntrospectionSchema.h"
67

78
using namespace std::literals;
@@ -209,8 +210,7 @@ ObjectType::ObjectType(init&& params)
209210
{
210211
}
211212

212-
void ObjectType::AddInterfaces(
213-
std::vector<std::shared_ptr<const InterfaceType>>&& interfaces)
213+
void ObjectType::AddInterfaces(std::vector<std::shared_ptr<const InterfaceType>>&& interfaces)
214214
{
215215
_interfaces = std::move(interfaces);
216216

src/SchemaGenerator.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ bool Generator::outputHeader() const noexcept
142142
std::ofstream headerFile(_headerPath, std::ios_base::trunc);
143143
IncludeGuardScope includeGuard { headerFile, fs::path(_headerPath).filename().string() };
144144

145-
headerFile << R"cpp(#include "graphqlservice/GraphQLSchema.h"
146-
#include "graphqlservice/GraphQLService.h"
145+
headerFile << R"cpp(#include "graphqlservice/internal/Schema.h"
147146
148147
// Check if the library version is compatible with schemagen )cpp"
149148
<< graphql::internal::MajorVersion << R"cpp(.)cpp" << graphql::internal::MinorVersion

0 commit comments

Comments
 (0)