Class GraphQLSchemaParser

  • All Implemented Interfaces:

    
    public class GraphQLSchemaParser
    
                        

    Parses 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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      ViaductSchema parse(Reader reader) Parses a GraphQL schema from a Reader and returns the ViaductSchema.
      ViaductSchema parse(File schemaFile) Parses a GraphQL schema file and returns the ViaductSchema.
      ViaductSchema parse(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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GraphQLSchemaParser

        GraphQLSchemaParser()
    • 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 ViaductSchema
        packageName - 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 ViaductSchema
        packageName - 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 ViaductSchema
        packageName - the package name for generated objects
        includeRootTypes - 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 ViaductSchema
        packageName - 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 ViaductSchema
        packageName - 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 ViaductSchema
        packageName - 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 ViaductSchema
        packageName - the package name for generated argument types
        mutationTypeName - 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 ViaductSchema
        grtPackage - the package name for GRT types
        mutationTypeName - the name of the mutation type (or null if none)
        Returns:

        a map from type name to list of resolver models for that type