code: func FragmentsOnCompositeTypesRule(context *ValidationContext) *ValidationRuleInstance {
  	visitorOpts := &visitor.VisitorOptions{
  		KindFuncMap: map[string]visitor.NamedVisitFuncs{
  			kinds.InlineFragment: {
  				Kind: func(p visitor.VisitFuncParams) (string, interface{}) {
  					if node, ok := p.Node.(*ast.InlineFragment); ok {
  						ttype := context.Type()
  						if node.TypeCondition != nil && ttype != nil && !IsCompositeType(ttype) {
  							reportError(
  								context,
  								fmt.Sprintf(`Fragment cannot condition on non composite type "%v".`, ttype),
  								[]ast.Node{node.TypeCondition},
  							)
  						}
  					}
  					return visitor.ActionNoChange, nil
  				},
  			},
  			kinds.FragmentDefinition: {
  				Kind: func(p visitor.VisitFuncParams) (string, interface{}) {
  					if node, ok := p.Node.(*ast.FragmentDefinition); ok {
  						ttype := context.Type()
  						if ttype != nil && !IsCompositeType(ttype) {
  							nodeName := ""
  							if node.Name != nil {
  								nodeName = node.Name.Value
  							}
  							reportError(
  								context,
  								fmt.Sprintf(`Fragment "%v" cannot condition on non composite type "%v".`, nodeName, printer.Print(node.TypeCondition)),
  								[]ast.Node{node.TypeCondition},
  							)
  						}
  					}
  					return visitor.ActionNoChange, nil
  				},
  			},
  		},
  	}
  	return &ValidationRuleInstance{
  		VisitorOpts: visitorOpts,
  	}
  }
docs: // FragmentsOnCompositeTypesRule Fragments on composite type
  //
  // Fragments use a type condition to determine if they apply, since fragments
  // can only be spread into a composite type (object, interface, or union), the
  // type condition must also be a composite type.