Class GraphQLSchemaParser
-
- All Implemented Interfaces:
public class GraphQLSchemaParserParses GraphQL schema files and extracts type definitions using ViaductSchema types. This follows the same approach as the Kotlin codegen, using ViaductSchema as the abstraction layer instead of graphql-java types directly.
-
-
Constructor Summary
Constructors Constructor Description GraphQLSchemaParser()
-
Method Summary
Modifier and Type Method Description ViaductSchemaparse(Reader reader)Parses a GraphQL schema from a Reader and returns the ViaductSchema. ViaductSchemaparse(File schemaFile)Parses a GraphQL schema file and returns the ViaductSchema. ViaductSchemaparse(List<File> schemaFiles)Parses multiple GraphQL schema files and merges them into a ViaductSchema. List<EnumModel>extractEnums(ViaductSchema schema, String packageName)Extracts enum models from a ViaductSchema. List<ObjectModel>extractObjects(ViaductSchema schema, String packageName)Extracts object models from a ViaductSchema. List<ObjectModel>extractObjects(ViaductSchema schema, String packageName, boolean includeRootTypes)Extracts object models from a ViaductSchema with optional root type inclusion. List<InputModel>extractInputs(ViaductSchema schema, String packageName)Extracts input models from a ViaductSchema. List<InterfaceModel>extractInterfaces(ViaductSchema schema, String packageName)Extracts interface models from a ViaductSchema. List<UnionModel>extractUnions(ViaductSchema schema, String packageName)Extracts union models from a ViaductSchema. List<ArgumentModel>extractArguments(ViaductSchema schema, String packageName, String mutationTypeName)Extracts argument models from a ViaductSchema for resolver fields that have arguments. Map<String, List<ResolverModel>>extractResolvers(ViaductSchema schema, String grtPackage, String mutationTypeName)Extracts resolver models from a ViaductSchema by finding fields with @resolver directive. -
-
Method Detail
-
parse
ViaductSchema parse(Reader reader)
Parses a GraphQL schema from a Reader and returns the ViaductSchema.
- Parameters:
reader- the reader to parse from- Returns:
the ViaductSchema
-
parse
ViaductSchema parse(File schemaFile)
Parses a GraphQL schema file and returns the ViaductSchema.
- Parameters:
schemaFile- the schema file to parse- Returns:
the ViaductSchema
-
parse
ViaductSchema parse(List<File> schemaFiles)
Parses multiple GraphQL schema files and merges them into a ViaductSchema.
- Parameters:
schemaFiles- the schema files to parse- Returns:
the merged ViaductSchema
-
extractEnums
List<EnumModel> extractEnums(ViaductSchema schema, String packageName)
Extracts enum models from a ViaductSchema. Extensions are already merged in ViaductSchema.
- Parameters:
schema- the ViaductSchemapackageName- the package name for generated enums- Returns:
the list of enum models
-
extractObjects
List<ObjectModel> extractObjects(ViaductSchema schema, String packageName)
Extracts object models from a ViaductSchema. Excludes root types (Query, Mutation, Subscription).
- Parameters:
schema- the ViaductSchemapackageName- the package name for generated objects- Returns:
the list of object models
-
extractObjects
List<ObjectModel> extractObjects(ViaductSchema schema, String packageName, boolean includeRootTypes)
Extracts object models from a ViaductSchema with optional root type inclusion.
- Parameters:
schema- the ViaductSchemapackageName- the package name for generated objectsincludeRootTypes- if true, includes Query, Mutation, Subscription types- Returns:
the list of object models
-
extractInputs
List<InputModel> extractInputs(ViaductSchema schema, String packageName)
Extracts input models from a ViaductSchema.
- Parameters:
schema- the ViaductSchemapackageName- the package name for generated inputs- Returns:
the list of input models
-
extractInterfaces
List<InterfaceModel> extractInterfaces(ViaductSchema schema, String packageName)
Extracts interface models from a ViaductSchema.
- Parameters:
schema- the ViaductSchemapackageName- the package name for generated interfaces- Returns:
the list of interface models
-
extractUnions
List<UnionModel> extractUnions(ViaductSchema schema, String packageName)
Extracts union models from a ViaductSchema.
- Parameters:
schema- the ViaductSchemapackageName- the package name for generated unions- Returns:
the list of union models
-
extractArguments
List<ArgumentModel> extractArguments(ViaductSchema schema, String packageName, String mutationTypeName)
Extracts argument models from a ViaductSchema for resolver fields that have arguments.
- Parameters:
schema- the ViaductSchemapackageName- the package name for generated argument typesmutationTypeName- the name of the mutation type (or null if none)- Returns:
the list of argument models
-
extractResolvers
Map<String, List<ResolverModel>> extractResolvers(ViaductSchema schema, String grtPackage, String mutationTypeName)
Extracts resolver models from a ViaductSchema by finding fields with @resolver directive.
Groups resolvers by their containing type name. Each type with resolver fields will have an entry in the returned map.
- Parameters:
schema- the ViaductSchemagrtPackage- the package name for GRT typesmutationTypeName- the name of the mutation type (or null if none)- Returns:
a map from type name to list of resolver models for that type
-
-
-
-