Class OperationMapper


  • public class OperationMapper
    extends Object

    Drives the work of mapping Java structures into their GraphQL representations.

    While the task of mapping types is delegated to instances of TypeMapper, selection of mappers, construction and attachment of resolvers (modeled by DataFetchers in graphql-java), and other universal tasks are encapsulated in this class.
    • Constructor Detail

      • OperationMapper

        public OperationMapper​(String queryRoot,
                               String mutationRoot,
                               String subscriptionRoot,
                               BuildContext buildContext)
        Parameters:
        buildContext - The shared context containing all the global information needed for mapping
    • Method Detail

      • toGraphQLField

        public graphql.schema.GraphQLFieldDefinition toGraphQLField​(String parentType,
                                                                    Operation operation,
                                                                    BuildContext buildContext)
        Maps a single operation to a GraphQL output field (as queries in GraphQL are nothing but fields of the root operation type).
        Parameters:
        operation - The operation to map to a GraphQL output field
        buildContext - The shared context containing all the global information needed for mapping
        Returns:
        GraphQL output field representing the given operation
      • toGraphQLInputField

        public graphql.schema.GraphQLInputObjectField toGraphQLInputField​(InputField inputField,
                                                                          BuildContext buildContext)
        Maps a single field/property to a GraphQL input field.
        Parameters:
        inputField - The field/property to map to a GraphQL input field
        buildContext - The shared context containing all the global information needed for mapping
        Returns:
        GraphQL input field representing the given field/property
      • toGraphQLDirective

        public graphql.schema.GraphQLDirective toGraphQLDirective​(Directive directive,
                                                                  BuildContext buildContext)
      • toGraphQLAppliedDirective

        public graphql.schema.GraphQLAppliedDirective toGraphQLAppliedDirective​(Directive directive,
                                                                                BuildContext buildContext)
      • getQueries

        public List<graphql.schema.GraphQLFieldDefinition> getQueries()
        Fetches all the mapped GraphQL fields representing top-level queries, ready to be attached to the root query type.
        Returns:
        A list of GraphQL fields representing top-level queries
      • getMutations

        public List<graphql.schema.GraphQLFieldDefinition> getMutations()
        Fetches all the mapped GraphQL fields representing mutations, ready to be attached to the root mutation type.
        Returns:
        A list of GraphQL fields representing mutations
      • getSubscriptions

        public List<graphql.schema.GraphQLFieldDefinition> getSubscriptions()
      • getDirectives

        public Collection<graphql.schema.GraphQLDirective> getDirectives()
      • getSchemaDirectives

        public List<graphql.schema.GraphQLAppliedDirective> getSchemaDirectives()
      • getBatchResolvers

        public Map<String,​org.dataloader.BatchLoaderWithContext<?,​?>> getBatchResolvers()