Make a field AST for a node field.

 field - The GraphQL::Field instance to make the fragment for.

 Returns a GraphQL::Language::Nodes::Field instance.
768308
def node_field_ast(field)
      f_ast = field_ast(field)
      return nil if f_ast.nil?
      type = field.type.unwrap
      selections = f_ast.selections.dup

      if type.kind.object?
        selections << field_ast(type.get_field('id'))
      else
        possible_node_types(type).each do |if_type|
          selections << inline_fragment_ast(if_type, with_children: false)
        end
      end

      selections.compact!

      if f_ast.respond_to?(:merge) # GraphQL-Ruby 1.9+
        f_ast = f_ast.merge(selections: selections)
      else
        f_ast.selections = selections
      end
      f_ast
    end
1346168
def process_base_field(cls, field, key):
        
        if not field.name:
            field.name = key
        elif key != field.name:
            if not isinstance(field.alias, list):
                field.alias = [key]
            else:
                field.alias.insert(0, key)
            setattr(cls, field.name, field)

        cls.prepare_field(field)

        if field.alias:
            for alias_name in field.alias:
                if key is not alias_name:
                    setattr(cls, alias_name, field)
575355
def _validate_field_can_be_tagged_with_redactor(self, field):
        
        if is_alias(field.data_type):
            raise InvalidSpec(
                "Redactors can only be applied to alias definitions, not "
                "to alias references.",
                field._ast_node.lineno, field._ast_node.path)

        self._validate_object_can_be_tagged_with_redactor(field)
796137
def field=(field)
      validator = EnumAttributeValidator.new('String', ["START_AT", "END_AT", "CREATED_AT", "UPDATED_AT"])
      unless validator.valid?(field)
        fail ArgumentError, "invalid value for 'field', must be one of #{validator.allowable_values}."
      end
      @field = field
    end
1220781
async def field(self, elem=None, elem_type=None, params=None):
        
        elem_type = elem_type if elem_type else elem.__class__
        fvalue = None

        etype = self._get_type(elem_type)
        if self._is_type(etype, UVarintType):
            fvalue = await self.uvarint(get_elem(elem))

        elif self._is_type(etype, IntType):
            fvalue = await self.uint(
                elem=get_elem(elem), elem_type=elem_type, params=params
            )

        elif self._is_type(etype, BlobType):
            fvalue = await self.blob(
                elem=get_elem(elem), elem_type=elem_type, params=params
            )

        elif self._is_type(etype, UnicodeType):
            fvalue = await self.unicode_type(get_elem(elem))

        elif self._is_type(etype, VariantType):
            fvalue = await self.variant(
                elem=get_elem(elem), elem_type=elem_type, params=params
            )

        elif self._is_type(etype, ContainerType):  # container ~ simple list
            fvalue = await self.container(
                container=get_elem(elem), container_type=elem_type, params=params
            )

        elif self._is_type(etype, TupleType):  # tuple ~ simple list
            fvalue = await self.tuple(
                elem=get_elem(elem), elem_type=elem_type, params=params
            )

        elif self._is_type(etype, MessageType):
            fvalue = await self.message(get_elem(elem), msg_type=elem_type)

        else:
            raise TypeError(
                "unknown type: %s %s %s" % (elem_type, type(elem_type), elem)
            )

        return fvalue if self.writing else set_elem(elem, fvalue)
973156
def build_field(self, field_name, info, model_class, nested_depth):
        
        if field_name in info.fields_and_pk:
            model_field = info.fields_and_pk[field_name]
            return self.build_standard_field(field_name, model_field)

        elif field_name in info.relations:
            relation_info = info.relations[field_name]
            if not nested_depth:
                return self.build_relational_field(field_name, relation_info)
            else:
                return self.build_nested_field(field_name, relation_info, nested_depth)

        elif hasattr(model_class, field_name):
            return self.build_property_field(field_name, model_class)

        elif field_name == self.url_field_name:
            return self.build_url_field(field_name, model_class)

        return self.build_unknown_field(field_name, model_class)
37878
def put_field(self, field):
        
        fpath = self.fields_json_path(field)
        # Open fields JSON, locking to prevent other processes
        # reading or writing
        with InterProcessLock(fpath + self.LOCK_SUFFIX, logger=logger):
            try:
                with open(fpath, 'r') as f:
                    dct = json.load(f)
            except IOError as e:
                if e.errno == errno.ENOENT:
                    dct = {}
                else:
                    raise
            if field.array:
                dct[field.name] = list(field.value)
            else:
                dct[field.name] = field.value
            with open(fpath, 'w') as f:
                json.dump(dct, f, indent=2)
1218712
public static Field cloneField(Field field) {
    return new Field(field.name(), field.schema(), field.doc(),
        field.defaultValue());
  }
746633
def field(tag, modifier = nil)
      fields.detect { |field| field.tag == tag.to_s && (modifier.nil? || field.modifier == modifier) }
    end
403337
def convert_serializer_field(field, is_input=True):
    

    graphql_type = get_graphene_type_from_serializer_field(field)

    args = []
    kwargs = {"description": field.help_text, "required": is_input and field.required}

    # if it is a tuple or a list it means that we are returning
    # the graphql type and the child type
    if isinstance(graphql_type, (list, tuple)):
        kwargs["of_type"] = graphql_type[1]
        graphql_type = graphql_type[0]

    if isinstance(field, serializers.ModelSerializer):
        if is_input:
            graphql_type = convert_serializer_to_input_type(field.__class__)
        else:
            global_registry = get_global_registry()
            field_model = field.Meta.model
            args = [global_registry.get_type_for_model(field_model)]
    elif isinstance(field, serializers.ListSerializer):
        field = field.child
        if is_input:
            kwargs["of_type"] = convert_serializer_to_input_type(field.__class__)
        else:
            del kwargs["of_type"]
            global_registry = get_global_registry()
            field_model = field.Meta.model
            args = [global_registry.get_type_for_model(field_model)]

    return graphql_type(*args, **kwargs)
910273
def get_field(field, default = nil)
      value = fields[field]
      value = default if !default.nil? && (value.nil? || (value.respond_to?(:empty?) && value.empty?))
      value
    end
456940
def build(self, field: Field) -> Mapping[str, Any]:
        
        return dict(self.iter_parsed_values(field))
441983
def as_uni_field(field):
    
    template = get_template('uni_form/field.html')
    c = Context({'field':field})
    return template.render(c)
1346713
def get_field(expr, field):
    
    weld_obj = WeldObject(encoder_, decoder_)

    struct_var = weld_obj.update(expr)
    if isinstance(expr, WeldObject):
        struct_var = expr.obj_id
        weld_obj.dependencies[struct_var] = expr

    weld_template = """
      %(struct)s.$%(field)s
    """

    weld_obj.weld_code = weld_template % {"struct":struct_var,
                                          "field":field}
    return weld_obj
1150421
def get_fields(node, fields_tag="field_list"):
    
    fields_nodes = [c for c in node.children if c.tagname == fields_tag]
    if len(fields_nodes) == 0:
        return {}
    assert len(fields_nodes) == 1, "multiple nodes with tag " + fields_tag
    fields_node = fields_nodes[0]
    fields = [
        {f.tagname: f.rawsource.strip() for f in n.children}
        for n in fields_node.children
        if n.tagname == "field"
    ]
    return {f["field_name"]: f["field_body"] for f in fields}
918977
def field(name, klass, stringify = nil, default = nil, validate = nil, msg ='')
      fields << name

      # getter
      define_method name do
        instance_variable_get( "@#{name}" )
      end

      # setter (includes validations)
      define_method "#{name}=" do | val |
        if val.nil? && default
          # Leave value as nil, so that default is used.
        elsif validate.kind_of?(Regexp)
          unless val =~ validate
            raise InvalidError, "#{val} does not match Regexp #{validate} for field #{name}"
          end
        elsif validate.respond_to?(:call) # Proc with value as argument
          unless validate.call(val)
            raise InvalidError, "#{val} does not pass validation Proc for field #{name}"
          end
        end

        instance_variable_set( "@#{name}", val )
      end

      # to_ach
      define_method  "#{name}_to_ach" do
        val = instance_variable_get( "@#{name}" )

        if val.nil?
          if default.kind_of?(Proc)
            val = default.call
          elsif default
            val = default
          else
            raise RuntimeError, "val of #{name} is nil"
          end
        end

        if val.kind_of?(String)
          if RUBY_VERSION < '1.9'
            val = Iconv.conv('ASCII//IGNORE', 'UTF8', val)
          else
            val = val.encode Encoding.find('ASCII'), ENCODING_OPTIONS
          end
        end

        if stringify
          stringify.call(val)
        else
          val
        end
      end
    end
823780
public function field($field, $alias = null) {
        if (is_string($field)) {
            $fields = explode(',', trim($field));
            foreach ($fields as $field) {
                $this->fields [] = Condition::cleanField($field . ($alias ? ' AS ' . $alias : ''));
            }
        } else if ($field instanceof Query) {
            if ($alias) {
                $field->alias($alias);
            }
            $this->fields [] = $field;
        } else if ($field instanceof ImmutableValue) {
            if ($alias) {
                $field->alias($alias);
            }
            $this->fields [] = $field;
        }

        return $this;
    }