Skip to content

Commit f0f5f2d

Browse files
author
Rick Marry
authored
fix: [BT-1616]: speed up graphql schema load time (#36218)
* fix: [BT-1616]: reduce the number of times we load the schema files from 3 to 2 * fix: [BT-1616]: take out unnecessary if null checks when in init * fix: [BT-1616]: reformat and optimize imports
1 parent ab6eefc commit f0f5f2d

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

400-rest/src/main/java/software/wings/graphql/provider/GraphQLProvider.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,15 @@ public class GraphQLProvider implements QueryLanguageProvider<GraphQL> {
5656

5757
@Inject
5858
public void init() {
59-
if (privateGraphQL == null) {
60-
String[] allPaths = new String[] {GRAPHQL_SCHEMA_PRIVATE_DIRECTORY_PATH, GRAPHQL_SCHEMA_PUBLIC_DIRECTORY_PATH};
61-
privateGraphQL = getGraphQL(allPaths);
62-
}
63-
64-
if (publicGraphQL == null) {
65-
String[] allPaths = new String[] {GRAPHQL_SCHEMA_PUBLIC_DIRECTORY_PATH};
66-
publicGraphQL = getGraphQL(allPaths);
67-
}
59+
TypeDefinitionRegistry typeDefinitionRegistry = new TypeDefinitionRegistry();
60+
publicGraphQL = getGraphQL(GRAPHQL_SCHEMA_PUBLIC_DIRECTORY_PATH, typeDefinitionRegistry);
61+
privateGraphQL = getGraphQL(GRAPHQL_SCHEMA_PRIVATE_DIRECTORY_PATH, typeDefinitionRegistry);
6862
}
6963

70-
private GraphQL getGraphQL(String[] paths) {
64+
private GraphQL getGraphQL(String path, TypeDefinitionRegistry typeDefinitionRegistry) {
7165
SchemaParser schemaParser = new SchemaParser();
72-
TypeDefinitionRegistry typeDefinitionRegistry = new TypeDefinitionRegistry();
7366

74-
for (String path : paths) {
75-
loadSchemaForEnv(path, typeDefinitionRegistry, schemaParser);
76-
}
67+
loadSchemaForEnv(path, typeDefinitionRegistry, schemaParser);
7768
RuntimeWiring runtimeWiring = buildRuntimeWiring();
7869

7970
SchemaGenerator schemaGenerator = new SchemaGenerator();

0 commit comments

Comments
 (0)