Class GraphQLCodeRegistry.Builder

  • Enclosing class:
    GraphQLCodeRegistry

    public static class GraphQLCodeRegistry.Builder
    extends java.lang.Object
    • Method Detail

      • trackChanges

        public GraphQLCodeRegistry.Builder trackChanges()
        A helper method to track if the builder changes from the point at which this method was called.
        Returns:
        this builder for fluent code
      • hasChanged

        public boolean hasChanged()
        Returns:
        true if the builder has changed since trackChanges() was called
      • getDataFetcher

        public DataFetcher<?> getDataFetcher​(GraphQLObjectType parentType,
                                             GraphQLFieldDefinition fieldDefinition)
        Returns a data fetcher associated with a field within an object type
        Parameters:
        parentType - the container type
        fieldDefinition - the field definition
        Returns:
        the DataFetcher associated with this field. All fields have data fetchers
      • getDataFetcher

        public DataFetcher<?> getDataFetcher​(FieldCoordinates coordinates,
                                             GraphQLFieldDefinition fieldDefinition)
        Returns a data fetcher associated with a field located at specified coordinates.
        Parameters:
        coordinates - the field coordinates
        fieldDefinition - the field definition
        Returns:
        the DataFetcher associated with this field. All fields have data fetchers
      • getDefaultDataFetcherFactory

        public DataFetcherFactory<?> getDefaultDataFetcherFactory()
        Returns:
        the default data fetcher factory associated with this code registry
      • hasDataFetcher

        public boolean hasDataFetcher​(FieldCoordinates coordinates)
        Returns true if the code registry contained a data fetcher at the specified co-ordinates
        Parameters:
        coordinates - the field coordinates
        Returns:
        the true if there is a data fetcher at those co-ordinates
      • getTypeResolver

        public TypeResolver getTypeResolver​(GraphQLInterfaceType interfaceType)
        Returns the type resolver associated with this interface type
        Parameters:
        interfaceType - the interface type
        Returns:
        a non null TypeResolver
      • hasTypeResolver

        public boolean hasTypeResolver​(java.lang.String typeName)
        Returns true of a type resolver has been registered for this type name
        Parameters:
        typeName - the name to check
        Returns:
        true if there is already a type resolver
      • getTypeResolver

        public TypeResolver getTypeResolver​(GraphQLUnionType unionType)
        Returns the type resolver associated with this union type
        Parameters:
        unionType - the union type
        Returns:
        a non null TypeResolver
      • dataFetcher

        public GraphQLCodeRegistry.Builder dataFetcher​(FieldCoordinates coordinates,
                                                       DataFetcher<?> dataFetcher)
        Sets the data fetcher for a specific field inside a container type
        Parameters:
        coordinates - the field coordinates
        dataFetcher - the data fetcher code for that field
        Returns:
        this builder
      • systemDataFetcher

        public GraphQLCodeRegistry.Builder systemDataFetcher​(FieldCoordinates coordinates,
                                                             DataFetcher<?> dataFetcher)
        Called to place system data fetchers (eg Introspection fields) into the mix
        Parameters:
        coordinates - the field coordinates
        dataFetcher - the data fetcher code for that field
        Returns:
        this builder
      • dataFetcher

        public GraphQLCodeRegistry.Builder dataFetcher​(FieldCoordinates coordinates,
                                                       DataFetcherFactory<?> dataFetcherFactory)
        Sets the data fetcher factory for a specific field inside a container type
        Parameters:
        coordinates - the field coordinates
        dataFetcherFactory - the data fetcher factory code for that field
        Returns:
        this builder
      • dataFetcherIfAbsent

        public GraphQLCodeRegistry.Builder dataFetcherIfAbsent​(FieldCoordinates coordinates,
                                                               DataFetcher<?> dataFetcher)
        Sets the data fetcher factory for a specific field inside a container type ONLY if not mapping has already been made
        Parameters:
        coordinates - the field coordinates
        dataFetcher - the data fetcher code for that field
        Returns:
        this builder
      • dataFetchers

        public GraphQLCodeRegistry.Builder dataFetchers​(java.lang.String parentTypeName,
                                                        java.util.Map<java.lang.String,​DataFetcher<?>> fieldDataFetchers)
        This allows you you to build all the data fetchers for the fields of a container type.
        Parameters:
        parentTypeName - the parent container type
        fieldDataFetchers - the map of field names to data fetchers
        Returns:
        this builder
      • defaultDataFetcher

        public GraphQLCodeRegistry.Builder defaultDataFetcher​(DataFetcherFactory<?> defaultDataFetcherFactory)
        This is the default data fetcher factory that will be used for fields that do not have specific data fetchers attached. By default PropertyDataFetcher is used but you can have your own default via this method.
        Parameters:
        defaultDataFetcherFactory - the default data fetcher factory used
        Returns:
        this builder